Thread: Regex question
View Single Post
Old 09-30-2022, 09:56 AM   #2
Tex2002ans
Wizard
Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.
 
Posts: 2,306
Karma: 13057279
Join Date: Jul 2012
Device: Kobo Forma, Nook
Quote:
Originally Posted by skil-phil View Post
What am I missing?
Thanks
A '+' sign.

In Regex, + means "ONE OR MORE of the previous thing".
  • \w = any word or number character
  • \w+ = ONE OR MORE of any word or number character

Or:
  • [a-zA-Z0-9] = Look for a lowercase "a through z", capital "A through Z", or number "0 through 9".
  • [a-zA-Z0-9]+ = Look for ONE OR MORE of lowercase...

You also have other symbols/methods too:
  • \w* = ZERO OR MORE of...
  • \w? = ZERO OR ONE of...
  • \w{4} = EXACTLY 4 of...
  • \w{3,10} = Anywhere between 3 to 10 of...

- - -

Side Note: I'd highly recommend looking at some of my step-by-step breakdowns of regex over the years...

Here's a few of them:

I explain what each piece does, and many times, I even color-coordinate everything with colors to make it easier to understand which piece does what.

You may also want to type this into your favorite search engine:

Code:
 Tex2002ans regular expressions site:mobileread.com
 Tex2002ans regular expressions site:reddit.com
I've written hundreds of posts over the years about regex.

Last edited by Tex2002ans; 09-30-2022 at 10:06 AM.
Tex2002ans is offline   Reply With Quote