This question already has answers here:
Regex: ignore case sensitivity
(15 answers)
Closed 2 years ago.
Any ideas why this regex doesn't match everything from my string? (I want it to match discord.gg/XUGswJ)
[a-z] means lowercase letters. You probably want [a-zA-Z] to include uppercase.
Related
This question already has answers here:
What is a word boundary in regex?
(13 answers)
Difference between \b and \B in regex
(10 answers)
Regex using word boundary but word ends with a . (period)
(4 answers)
Closed 3 months ago.
I am trying to match an exact word with multiple patterns using regex.
What I tried:
pattern: "\b(#DOG|#DOG1|#DOG2)\b", text: "#DOG2".
I want to match exact text "#DOG2" using these patterns, and the expected result should be: there is only 1 match "#DOG2". How can I change the pattern text to achieve this?
Interestingly, if I remove all '#' symbol from above text, the regex will work as expected:
pattern: "\b(DOG|DOG1|DOG2)\b", text: "DOG2".
Does '#' affect the result? How can I avoid this?
This question already has answers here:
Regular Expressions: How to Express \w Without Underscore
(7 answers)
Why is an underscore (_) not regarded as a non-word character?
(4 answers)
Closed 2 years ago.
I thought \w should match only letters(in many different languages) and numbers.
I use regex to search songs on my disk.
pattern "song\W+artist" will match "song - artist", "'song' artist", "song(artist)" etc.
But it won't match "song _ artist", because "_" considered as a letter.
Why?
btw I can use pattern "song[^A-Za-z]+artist" but this will work only with latin symbols.
This question already has answers here:
regex: required character in brackets
(3 answers)
Closed 4 years ago.
I am working for something and writing a regular expression to capture a string which is either (numbers and letters) or only numbers.
I know a regex for only number is [0-9] and alphanumeric is [A-Za-z0-9] . But this would capture even the strings which are only letters. How do i force it to not have only letters? Is there a way to do it in a single regex?
([0-9]*[a-zA-Z]*[0-9])+([a-zA-Z]*)
This should solve your problem.
You can test it here
This question already has answers here:
What's the regular expression that matches a square bracket?
(10 answers)
Closed 6 years ago.
I want to allow [] these brackets in a name field using regex. Please help me on this.
Just escape them using \:
\[
\]
This question already has answers here:
Regex match entire words only
(7 answers)
Closed 7 years ago.
var text = 'word otherword';
I want to select words that only matches with 'word'. When i use simply /word/ for regex pattern, then it also selects the 'word' part in 'otherword'. I dont need that word(in this case 'otherword').So how can i only select/match 'word' word using regex?
Use word boundary - \b.
/\bword\b/