From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

The Daily CLAD

Community Browser
cancel
Showing results for 
Search instead for 
Did you mean: 

Re: Match Regular Expression Series: 1 of 5 ....scan that string....

SercoSteveB
Active Participant

What are the contents of String Array Out following execution of the VI?

 

Match Regular Expression 1 of 5.png

 

NOTE:  Answer d) has an empty array element at index 3.

 

Match Regular Expression 1 of 5 Answers.png

Comments
Timsrice
Member

B

 

I tried to extend this to work on a string with more than one line...

snippet.png

This will split the 'words' if they are separated by TAB, CARRIAGE RETURN, NEW LINE, or SPACE.

Do people think [^ ] or [^\s] is the more 'readable' when looking at the diagram?

crossrulz
Knight of NI

Always use the \s.  That white space could be a tab for all we know.


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
Timsrice
Member

Thanks for your view crossrulz - sounds like good advice.

 

 

Perhaps this is a better approach...

snippet.png

W for a 'word'

Matt-A.
Member

B.   Great inputs. 

nik35324
Member

B

MrStevenUND
Member

B

/s adds clarity.  Use slash codes!

SercoSteveB
Active Participant

Answer: B.  Nice one all.  Some good variations from Timsrice and from crossrulz around code readability.

 

I agree \s is way better from a readability standpoint, I will do better next time.

mon3am
Member

hi steve 

is the match pattern and the match  regular expression included in the CLAD exam?

thanks

SercoSteveB
Active Participant

Hi mon3am, I would say yes, but your guess is as good as mine.  The CLAD2017 Preparation Guide has a question that uses Match Pattern (Page 26 Question 9).  Match Pattern and Match Regular Expression are also useful when building questions around Loops, Shift Registers etc. so you might see them used because of that.   I guess the difficult bit is how much of the Regular Expression syntax you will need to remember.   The guide gives us a hint here also and leads me to think that simple syntax (a comma, see page 26 question 9) might be tested.

levonsg
Member

B

https://images.youracclaim.com/size/340x340/images/2edb5b1a-9414-44e1-8519-c774fc6dd079/36015_Certificate_Badges_FINAL__1__NI_Instructor_v5.png