11.6. Regex Examples: single character

Any line that has an 'x' in it.

Regex: /x/  
Input: "abcde"
Input: "abxcde"
Input: "xabcde"

Any line that starts with an 'x'.

Regex: /^x/  
Input: "abcde"
Input: "abxcde"
Input: "xabcde"
Input: " xabcde"

^ at the beginning of the regular expression means, match at the beginning of the string.


If you are interested in on-site trainings by the author, please contact me directly.

Online courses:

Would you like to get
updated when I publish
the next article?

Follow me:

Google Plus Twitter RSS feed