I need to come up with a regex to look for only letters A, F or E on the position 9 of a given text. I am really new with regex, did some searching and couldn't find any similar response. what i have so far is:
/^.{9}A/
This command seems to work to find letter A on the space nine, but how can I add the other 2 letters to the regex?
To match a character having special meaning in regex, you need to use a escape sequence prefix with a backslash ( \ ). E.g., \. matches "." ; regex \+ matches "+" ; and regex \( matches "(" . You also need to use regex \\ to match "\" (back-slash).
(. *?) matches any character ( . ) any number of times ( * ), as few times as possible to make the regex match ( ? ). You'll get a match on any string, but you'll only capture a blank string because of the question mark.
For example, the replacement pattern $1 indicates that the matched substring is to be replaced by the first captured group.
You say you're looking for C, F or E but looking for A in your example, so please include in the brackets any other letters you want to match, but what you're looking for is:
/^.{8}[CFE]/
It should be {8}
rather than {9}
because the way you had it, it'll match the first 9 characters and then match your letter in position 10.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With