LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to search for a string phrase containing a changing number

Solved!
Go to solution

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.

0 Kudos
Message 1 of 10
(914 Views)

Try Lum[1-2]naryKnight

 

Also read the help for Match Regular Expression or Match Pattern for more expression examples

========================
=== Engineer Ambiguously ===
========================
Message 2 of 10
(904 Views)

Check the help for Special Characters for Match Regular Expression 

LVNinja_0-1725459398609.png

 

0 Kudos
Message 3 of 10
(896 Views)
Solution
Accepted by LuminaryKnight

@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.

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

Message 4 of 10
(875 Views)

@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.

0 Kudos
Message 5 of 10
(856 Views)

@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."

0 Kudos
Message 6 of 10
(842 Views)
Solution
Accepted by LuminaryKnight

@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

========================
=== Engineer Ambiguously ===
========================
Message 7 of 10
(837 Views)
Solution
Accepted by LuminaryKnight

jcarmody_0-1725468409473.png

 

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

Message 8 of 10
(832 Views)

Well now I don't know whose answer to accept. But... thank you!  Extremely helpful.  Solved my issue.

0 Kudos
Message 9 of 10
(816 Views)

@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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 10 of 10
(807 Views)