09-04-2024 09:01 AM
Hello. I've been digging through Scan From String to figure out a way to essentially search for a string/phrase that contains a possibly changing number. So an example...
Words words words words words Lum1naryKnight words words word words. But it's possible the phrase is instead Lum2naryKnight.
Any suggestions/help here would be greatly appreciated.
Solved! Go to Solution.
09-04-2024 09:09 AM - edited 09-04-2024 09:10 AM
Try Lum[1-2]naryKnight
Also read the help for Match Regular Expression or Match Pattern for more expression examples
09-04-2024 09:16 AM
Check the help for Special Characters for Match Regular Expression
09-04-2024 09:36 AM
@RTSLVU wrote:
Try Lum[1-2]naryKnight
Also read the help for Match Regular Expression or Match Pattern for more expression examples
Or Lum[\d*]naryKnight to handle any integer.
* old punch line: Now you have two problems.
09-04-2024 10:53 AM - edited 09-04-2024 11:05 AM
@LuminaryKnight wrote:
Hello. I've been digging through Scan From String to figure out a way to essentially search for a string/phrase that contains a possibly changing number. So an example...
Words words words words words Lum1naryKnight words words word words. But it's possible the phrase is instead Lum2naryKnight.
Any suggestions/help here would be greatly appreciated.
"possible changing number" is too vague to offer a solution. Let's assume from the sparse examples that "number" is a positive integer (no decimal point, scientific format, minus sign, etc.), but you have not defined what the possible range is (single digit? multiple digits?, etc.). Is the word delimited always a <space> (not tab, linefeed, etc.)
Are e.g. all the following valid inputs?
What do you want to get out of it? The word with the changing number? The numerical value?
How long is the entire words string? Can the "special word" occur zero or multiple times? Can other words contain embedded integers to find? Is the "special" word case sensitive?
so. many. questions.
09-04-2024 11:36 AM - edited 09-04-2024 11:38 AM
@altenbach wrote:
@LuminaryKnight wrote:
Hello. I've been digging through Scan From String to figure out a way to essentially search for a string/phrase that contains a possibly changing number. So an example...
Words words words words words Lum1naryKnight words words word words. But it's possible the phrase is instead Lum2naryKnight.
Any suggestions/help here would be greatly appreciated.
"possible changing number" is too vague to offer a solution. Let's assume from the sparse examples that "number" is a positive integer (no decimal point, scientific format, minus sign, etc.), but you have not defined what the possible range is (single digit? multiple digits?, etc.). Is the word delimited always a <space> (not tab, linefeed, etc.)
Are e.g. all the following valid inputs?
- "Words words words words words Lum1naryKnight words words word words"
- "Words words words words words lum1naryknight words words word words"
- "Words words words words words Lum1naryKnight. words words word words"
- "Words words words words words Lum1naryKnight, words words word words"
- "Words words words words words Lum0naryKnight words words word words"
- "Words words words words words Lum123456789naryKnight words words word words"
- "Words words words words words LumnaryKnight words words word words"
What do you want to get out of it? The word with the changing number? The numerical value?
How long is the entire words string? Can the "special word" occur zero or multiple times? Can other words contain embedded integers to find? Is the "special" word case sensitive?
so. many. questions.
Let's say every option is viable except the last one, LumnaryKnight.
Let's also say that of those variable "words", "Knight" and "Lum" and "nary" could be hidden or scattered amongst them. Which is why it's imperative to find specifically, Lum#naryKnight
To keep things dynamic, I'd prefer to program for multidigit. But, we can limit the scope to "no decimal point."
09-04-2024 11:40 AM
@LuminaryKnight wrote:
Let's say every option is viable except the last one, LumnaryKnight.
Let's also say that of those variable "words", "Knight" and "Lum" and "nary" could be hidden or scattered amongst them. Which is why it's imperative to find specifically, Lum#naryKnight
To keep things dynamic, I'd prefer to program for multidigit. But, we can limit the scope to "no decimal point."
Lum[0-9]+naryKnight
09-04-2024 11:47 AM
09-04-2024 11:53 AM
Well now I don't know whose answer to accept. But... thank you! Extremely helpful. Solved my issue.
09-04-2024 12:02 PM
@LuminaryKnight wrote:
Well now I don't know whose answer to accept. But... thank you! Extremely helpful. Solved my issue.
You can mark multiple solutions. But I would say jcarmody's post is the most complete solution.