Jump to content

Regular expression won't work in a web browser.


gregaryb

Recommended Posts

I really over these things - can some one please just fix them for me so I can move on.

At this point I am not interested in learning the syntax for regular expressions as used in a web browser.

What is the problem with these?

Unable to check <input pattern='^@\s]+@[^@\s]+\.[^@\s]+$'> because the pattern is not a valid regexp: raw bracket is not allowed in regular expression with unicode flag 22 new_tradie.php

Unable to check <input pattern='^[a-zA-Z0-9]+[a-zA-Z0-9-\s,():'\.\[\]]*$'> because the pattern is not a valid regexp: character class escape cannot be used in class range in regular expression

Link to comment
Share on other sites

  • 5 weeks later...

It looks like there are syntax errors in your regular expressions. Let me help you fix them:

1. The first regular expression has a syntax error. The corrected version should be:
   <input pattern='^@[^\s]+@[^@\s]+\.[^@\s]+$'>

   Changes made:
   - Removed the unnecessary square bracket after the `@`.
   - Corrected the pattern inside the square brackets to match any character that is not a whitespace.

2. The second regular expression also has a syntax error. The corrected version should be:
   <input pattern='^[a-zA-Z0-9]+[a-zA-Z0-9-\s,():\.'\[\]]*$'>
 

   Changes made:
   - Removed the unnecessary escape character before the single quote within the character class.
   - Escaped the dot (`.`) inside the character class to match a literal dot.
   - Removed the unnecessary backslash before the square bracket within the character class.

Please replace your existing patterns with these corrected versions. If you encounter any further issues or have specific requirements, feel free to ask!

Link to comment
Share on other sites

  • 2 months later...
On 11/10/2023 at 11:17 AM, gregaryb said:

I really over these things - can some one please just fix them for me so I can move on.

At this point I am not interested in learning the syntax for regular expressions as used in a web browser.

What is the problem with these?

Unable to check <input pattern='^@\s]+@[^@\s]+\.[^@\s]+$'> because the pattern is not a valid regexp: raw bracket is not allowed in regular expression with unicode flag 22 new_tradie.php

Unable to check <input pattern='^[a-zA-Z0-9]+[a-zA-Z0-9-\s,():'\.\[\]]*$'> because the pattern is not a valid regexp: character class escape cannot be used in class range in regular expression

It seems like you're encountering issues with the regular expressions used in your HTML input patterns. The error messages indicate that there are problems with the syntax of these regular expressions.

Let's break down the issues:

For the first pattern:

<input pattern='^@\s]+@[^@\s]+\.[^@\s]+$'>
The error message indicates that "raw bracket is not allowed in regular expression with unicode flag." This means there's an issue with the brackets ([ and ]). It seems like there might be a typo or a misplaced bracket in your expression. You may want to double-check the syntax and ensure that the brackets are properly balanced.

For the second pattern:
<input pattern='^[a-zA-Z0-9]+[a-zA-Z0-9-\s,():'\.\[\]]*$'>

The error message points out that "character class escape cannot be used in class range in regular expression." This suggests there's a problem with how you're using escape characters within character classes. The single quotes (') within the character class might be causing confusion. You should either escape them properly or remove them if they're not necessary.

To fix these issues, you might consider revising your regular expressions according to the error messages provided and ensure they adhere to the syntax rules for regular expressions. If you need further assistance with the specific patterns, feel free to provide more details or context, and I'd be happy to help further.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...