..been reading about RegularExpressions.
..still lost.
So how would I find just the first word in a sentence?
e.g. Sylvester is black. (Sylvester only)
e.g. Sylvester-cat is black. (Sylvester only)
All the blanks out of the sentence above?
Find a simpler tutorial than http://www.regular-expressions.info/ ?
RegularExpression-find first word/spaces
RegularExpression-find first word/spaces
MacBook Pro-M1 (2021), Sequoia 15.4, PB 6.20
Re: RegularExpression-find first word/spaces
Code: Select all
Dim Matches.s(0)
CreateRegularExpression(0, "^[\w]+")
ExtractRegularExpression(0, "Sylvester is black.", Matches())
Debug Matches(0)
ExtractRegularExpression(0, "Sylvester-cat is black.", Matches())
Debug Matches(0)Re: RegularExpression-find first word/spaces
Thanks Kale,
Lets see... "^[\w]+"
^ is start at beginning of string
[\w] is a special code for 'look for any alfa char'
+ is repeat (appears to repeat until there aren't any more alfa chars)
I'm studying your code and will be spending some time reading your suggested link.
Such a simple concept...
[later]
I ordered a book, 'Mastering Regular Expressions', from Amazon. That should answer all my questions.
Ya' know they're right here in town!
Lets see... "^[\w]+"
^ is start at beginning of string
[\w] is a special code for 'look for any alfa char'
+ is repeat (appears to repeat until there aren't any more alfa chars)
I'm studying your code and will be spending some time reading your suggested link.
Such a simple concept...
[later]
I ordered a book, 'Mastering Regular Expressions', from Amazon. That should answer all my questions.
Ya' know they're right here in town!
MacBook Pro-M1 (2021), Sequoia 15.4, PB 6.20
Re: RegularExpression-find first word/spaces
Quote from http://www.pcre.org/pcre.txt:[quote] \d any decimal digit
\D any character that is not a decimal digit
\h any horizontal whitespace character
\H any character that is not a horizontal whitespace character
\s any whitespace character
\S any character that is not a whitespace character
\v any vertical whitespace character
\V any character that is not a vertical whitespace character
\w any "word" character
\W any "non-word" character[/quote]
\D any character that is not a decimal digit
\h any horizontal whitespace character
\H any character that is not a horizontal whitespace character
\s any whitespace character
\S any character that is not a whitespace character
\v any vertical whitespace character
\V any character that is not a vertical whitespace character
\w any "word" character
\W any "non-word" character[/quote]
Windows 10 / Windows 7
PB Last Final / Last Beta Testing
PB Last Final / Last Beta Testing
Re: RegularExpression-find first word/spaces
Ho, helpy is back ! 
Re: RegularExpression-find first word/spaces
To be more precise, + means 1 or more (unlimited), where'as if i had used * it would mean 0 or more.WilliamL wrote: + is repeat (appears to repeat until there aren't any more alfa chars)
Regular expression aren't hard per'say, they're just very easy to get lost in.




