LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Match all characters excluding ones "inside the double quote"

I have a string with the structure like this "any characters" + !$abCD + "any characters".

I woud like to match the string  !$abCD (This string must include !$)

 

I intend to use the Match Regular Expression.

 

Thank you in advance.

0 Kudos
Message 1 of 18
(8,576 Views)

\!\$abCD will work.

 

I usually use https://regex101.com to test regexes. It gives direct and clear feedback.

Certified LabVIEW Architect
Message 2 of 18
(8,543 Views)

plusses part of the string? Or does the next part begin with the quote?

To build on @Thols post

\!\$[^"]* - matches all up until "

 

\!\$[^+]* - matches all up until +

 

/Y

 

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 3 of 18
(8,540 Views)

Or maybe you wanted to catch !$abCD only within the pluses? Then this will output it in  a submatch:

\+ (\!\$abCD) \+

Certified LabVIEW Architect
0 Kudos
Message 4 of 18
(8,533 Views)

Or if you want to catch everything within the pluses:

\+ ([^\)]+) \+

Certified LabVIEW Architect
0 Kudos
Message 5 of 18
(8,532 Views)

@Yamaeda wrote:

plusses part of the string? Or does the next part begin with the quote?

To build on @Thols post

\!\$[^"]* - matches all up until "

 

\!\$[^+]* - matches all up until +

 

/Y

 


The expected matching sometimes is #something, $something, %something or !#something, !$something, !%something.

How will the expression be?

0 Kudos
Message 6 of 18
(8,526 Views)

@thols wrote:

Or if you want to catch everything within the pluses:

\+ ([^\)]+) \+


Why do you use this expression [^\)] to catch everything?

and I would like to have the general expression to catch the strings excluding ones inside the quote.

The format of the desired strings has the prefixes such as !#,!$,!%, #,$,% (i.e, !#ABCD)

The input string can have one or more "+"

0 Kudos
Message 7 of 18
(8,524 Views)

@anhduy92 wrote:

@thols wrote:

Or if you want to catch everything within the pluses:

\+ ([^\)]+) \+


Why do you use this expression [^\)] to catch everything?

and I would like to have the general expression to catch the strings excluding ones inside the quote.

The format of the desired strings has the prefixes such as !#,!$,!%, #,$,% (i.e, !#ABCD)

The input string can have one or more "+"


'roof' is 'not' so [^)] matches everything _except_ end parenthesis. Then, as it's an end parenthesis after that, it'll match everything within a parenthesis and include the end parenthesis. If you only search for ')' it's usually greedy and'll grab the last one in the string. (There's an option that can make it 'lazy' and grab the first one).

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 8 of 18
(8,498 Views)

The lazy operator is .*? so in this case you should be able to use:

\+ (.*?+) \+

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 9 of 18
(8,496 Views)

This page (Rexegg: Mastering Quantifiers) might be useful when reading about lazy and greedy matching.

 

Remember that LabVIEW uses the PCRE library for regular expressions (at least when it is considering real regular expressions - sometimes LabVIEW has nodes that have regular-ish expressions with limited syntax but often faster execution: see the help for Match Pattern for an example)


GCentral
0 Kudos
Message 10 of 18
(8,480 Views)