Regex pattern matching specific word [closed] - javascript

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I have a text input on my html page. When a user tries to add a new watch I want it to start with WATCH_XXXX (X's are whatever the user inputs). It has to start with WATCH_ all caps with the underscore. I've tried a lot of different ways but I keep getting the "please match the requested format" pop-up. This was the last one I tried -> required pattern="^WATCH_[a-z]". Am I even close to getting this right?

This regex ^WATCH_[a-zA-Z]+$ should work
<form>
<input required pattern="^WATCH_[a-zA-Z]+$"/>
<input type="submit"/>
</form>

Do all characters after "WATCH_" have to be letters? If not ^WATCH_.* may work better.
Tested here: https://regex101.com/#javascript
Also a great learning tool I use for Regex: http://regexone.com/

Related

Finding file name with variables in between [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 months ago.
Improve this question
Having a hard time with Regex.
What would be the regex for finding a file name with variable in between them?
For eg:
File name : DON_2010_JOE_1222022.txt
In the above file name the words DON, JOE and the format .txt will remain constant. Rest numbers might change for every file. There could be characters as well instead of numbers in those two places.
What im looking for is basically something like DON_*_JOE_*.txt with * being whatever it could be.
Can someone please help me with this?
I tried DON_*_JOE_*.txt and obviously it did not work.
DON_(?<firstString>.*)_JOE_(?<secondString>.*).txt
You can use this. To access the specific group, you can use matcher.group("firstString").
In JavaScript:
"DON_2010_JOE_1222022.txt".match(/DON_.+_JOE_.+\.txt/)
whatever it could be
It is .+ except new lines.

Regex validation with address house number mandatory [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
This is my regex for address validation right now
^[a-z-A-Z\ \d\#\-\.\`\\\/\'\(\)]+$
Now I need to make sure the address has mandatory house number
I changed to:
^[\d*a-z-A-Z\ \d\#\-\.\`\\\/\'\(\)]+$
but it's not working.
I need to check against this address:
8952 West Auburn St
If you want a number, followed by any of these [a-z-A-Z\ \d#-.\/'()], this is what you are looking for
^\d{1}[a-z-A-Z\ \d#-.\/'()]+$
It mean, it starts with a digit, with a length of at least 1, then matches anything in the square brackets, as many characters if you want
You can see it in action (and test alternatives) here:
https://regex101.com/r/tehNbZ/1

How to choose between two words using JS regex [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I have a sentence example: I am just one man I', trying to capture am just on with the following regex, but it also captures I which is not what I need.
(?=I).*(?= man)
The result is: I am just one
I don't want extra capturing groups, only the full match which should be am just one.
change the first positive lookahead to a negative (?!I). This won't capture I
(?!I).*(?= one)
By saying look and match anything except I
(?=[^I ]).*(?= man)

Regular Expression character set only [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I tried this : [fl]ady?[ing] ?[rb]ug!?
I know [fl]ad[y]?(ing)? ?[br]ug!? is an answer
Can this be solved using character sets only? Must match both.
ladybug
fading rug!
I believe this should work for you
[fl]ad(y|ing)\s?[br]ug?
Check out http://www.regexpal.com/
Using character sets only? So, it doesn't matter what other letter combinations it matches as well? Mmm. Then
[fl]ad[giny]+[\sbrug!]+
would do. See: https://regex101.com/r/FJWJyM/1

set languge arabic for input and another in french in same form [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I turn JavaScript forum in espoire to find a solution to my problem because right now I do not know or seek "in php or JavaScript" good my problem is in a form that I veus create the user must enter the information of use in two different languages "Arabic and French" .and I wondered if y'avais a moyer for the language chagement be automatic. "Arabic language = in the book field has seized the Arab" and when I position myself in another field or seized must be in French language changes automatically to the French
I hope qulqu'un poura answer me.
Use lang attribute:
<input lang="fr">
<input lang="ar">

Categories