LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

RegExp help request here...

Solved!
Go to solution

I'm having some trouble with "Match by Regular Expression"- I was thinking some of you guys are really quick with this stuff and it might be easy for you to enlighten me for some kudos.

 

The current regex I'm trying to match is: "([^"]*)",?  

 

I beleive this says to match the longest string in quotes not containing any quotes- am I correct?  (I'm not the author of this original exp).

 

the comma-question-mark means there may be one or more ccommas after the string found?

 

Here's what I'm urrently causing errors trying to add - I need it to match the above regular expression OR a null string.  I though adding a pipe at the end might do it but it still caused the match to report "-1" on the offset past match.

 

Anyone have any ideas?

 

Thanks and kudos to any help!

-pat

0 Kudos
Message 1 of 5
(2,649 Views)

Have not tried to capture a null before but to me it sounds a lot like a blank line.

You might try a pipe with line anchors (I.E., |^$)

Message 2 of 5
(2,606 Views)

unfortunetly that didnt seem to work- thanks for the idea though!

 

EDIT:  I also tried throwing ( )? around the original regexp... still didnt work

 

EDIT#2:  correction the ( )? works but it then does not work with the original expression where it should match the content in quotes... 

0 Kudos
Message 3 of 5
(2,582 Views)
Solution
Accepted by plyons.gks

The '?' matches 0 or 1 occurrences of the character or grouping that precedes it. For 1 or more commas, you want +.

 

I think Don has the right idea. See if ("([^"]*)",?)|(^$) works for you. If not, can you post a sample string, and the expected output?

Message 4 of 5
(2,567 Views)

Yes!   that is it, I forgot the parenthases!  it works.

 

Kudos all'round

 

thanks again

-Pat

0 Kudos
Message 5 of 5
(2,560 Views)