RegEx Series: (Part 3) Special Characters

Wildcard, Zero or More Repetition & Optional Character

Introduction

This is the final installment of my special characters post within my regular expressions series. I will mention in this post, the wildcard character, optional character, and the zero or more repetitions character.

Optional Character

The optional character uses the ? in the regular expression. If you want to match a pure question mark for punctuation purposes, you will have to escape it like all special characters using the backslash\? .

Image for post
Image for post

Wildcard Character

The wildcard character is another interesting special character because it essentially will tell your pattern to match any character as long as it is not a newline character.

Image for post
Image for post
Image for post
Image for post

Zero Or More Repetition Character

The zero or more repetition character is also another useful special character and one that is indicated by a * character. This character will follow a character set or group and will check the characters that precede it. It makes the character that appears before it optional, but it can also appear up to an unlimited amount of times.

Image for post
Image for post

Conclusion

This is the end of my special characters section and in the next post, I will go over matching characters in different parts of the string such as at the end or the beginning of the string. See you next time!

Software Developer && Political Enthusiast

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store