[help] Regex match.
Scenario 1. Sentence A= Apple has some good phones.
Sentence B= Apple good phones
What I want to do:
- Count number of words in sentence B.
Posted Sep 22, 2021, 8:15 AM UTC
Scenario 1. Sentence A= Apple has some good phones.
Sentence B= Apple good phones
What I want to do:
Posted Sep 22, 2021, 8:15 AM UTC
Use variable search and replace;
Task: Count Words
A1: Variable Set [
Name: %boo
To: Apples are great
Max Rounding Digits: 3 ]
A2: Variable Search Replace [
Variable: %boo
Search: \w+
Store Matches In Array: %many ]
A3: Flash [
Text: %many(#) ]
The \w will catch single words, the + after means one or more of this type.
The
\wwill catch single words, the+after means one or more of this type.
single words a single word character
I never got why they say word character, as 0-9 are not really word characters 😛
I don't know either. I would be more inclined to say alphanumeric, but \w matches _ too. I guess as long as we know what it does, it doesn't matter what we call it.
I'll blame all the old farts on IRC who used to deal with usernames like Django_589 and got all whiney because their regexp was fugly for their karma and lolbots.
How is sentence A relevant?
If you split the string into an array using a space as a separator, your word count will be in %array(#). See the user guide under variables.