Help with Regular Expressions

Over the years I've tried several times to understand Regular Expressions, but none of the introductory lessons have worked for me. I just reviewed the KM wiki page on Regular Expressions but couldn't understand any of it. I can't even figure out the examples there. For many many years (OK dating back to 1981) I've used simpler (and less powerful) systems that I find easy to use without having to look at reference material. I'd much rather have an easier to use system (at the understood expense of power). Even something as simple as Excel's wildcards. With that in mind, would anyone be willing to provide the regular expressions that are equivalent to the following Excel patterns? (An * represents zero or more of any character; a ? represents any one character, and a ~ is the escape character). Specifically, what regular expression would work the same as each of the following?

? (any one character)
?? (any two characters)
th (ends in "th") [there should be an asterisk in front of th, but I can't seem to post that here]
?* (at least one character)
*?ember (ends with "ember" with at least one more character preceding)
xy?z (contains the following: "xy" followed by any single character followed by "z") [again, sorry, there should be an asterisk before and an asterisk after "xy?z" but the forum software strips it out]

I don't mind if you want to teach me to fish instead of giving me one--feel free to steer me towards a page that would teach me the how to figure out the above without teaching me much more than that. I rarely spot situations where I need more than basic wildcards, but often struggle with doing basic stuff with Regular Expressions. My goal here is to keep a few notes that will allow me to quickly do Excel-like wildcards in Regular Expressions.

Richard_Tench,

? == . 
?? == .{2}
th == th$
?* == .+
*?ember == .+ember$
*xy?z* == xy.{1}z

you can use www.regex101.com to interactively test regex.

4 Likes

Yes I also was clueless until I start using examples in regex

1 Like

Debuggex is a very good website to visualize your regex.

https://www.debuggex.com

3 Likes

Thank you all, this is a good start.