BreakPoint

cancel
Showing results for 
Search instead for 
Did you mean: 

Regular Expressions Board

I am stuck trying to create a single regular expression that will support two variations of a command...

 

What I have so far is:  ([^(0-9)]+|[a-zA-Z]+)([0-9]|[^[0-9]+(\.[0-9]{1,2})?$]|[\s]+)

 

One command supports multiple parameters.  The arguments look like this:

 

 

DBL[1] 2.5

VCC 2.35

 

The regular expression needs to breakdown the above into the following:

 

submatch1:  DBL[

submatch2:  1

aftermatch:   2.5

 

This works!

 

The next one does not:

 

submatch1:   VCC

submatch 2:  2

aftermatch:   .35

 

I wanted:

 

submatch1:   VCC

submatch 2:  \s

aftermatch:   2.35

 

I am not sure this can be done within a single regEx... I can get one or the other command expression to work, but not both..  😞

 

I may implement separate expressions..

 

0 Kudos
Message 101 of 150
(6,216 Views)

(\D+)(?:\[?([^\]]+)])?\s

Message 102 of 150
(6,211 Views)

Wow!!  Thanks Darin!

 

The Stig to the rescue! 

An impressively small regEx that does the trick! 

 

🙂

 

ASIDE NOTE:  My wife & I started watching Top Gear.  Those guys are funny.  Excellent show.

Message 103 of 150
(6,197 Views)

British or American version?

Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



0 Kudos
Message 104 of 150
(6,129 Views)

There's an American version??!!??  😮

0 Kudos
Message 105 of 150
(6,101 Views)

@Ray.R wrote:

There's an American version??!!??  😮


Shh.  We don't talk about that one.....

0 Kudos
Message 106 of 150
(6,081 Views)

I once saw the American version on BBC iPlayer here in the UK. Sorry guys, but it really doesn't compare.

 

Although I do like some of those muscle cars you guys are particularly good at building 🙂

Thoric (CLA, CLED, CTD and LabVIEW Champion)


Message 107 of 150
(6,037 Views)

@Darin.K wrote:

(\D+)(?:\[?([^\]]+)])?\s


Regular expressions still scare the hell outta me. This really means nothing I can understand, it's like hieroglyphics! Maybe one day I'll get my teeth into them properly - they look incredibly powerful!

 

Thoric (CLA, CLED, CTD and LabVIEW Champion)


0 Kudos
Message 108 of 150
(6,035 Views)

Just to see how big my eyes get when some of you get ahold of this and manage it with about 2 keystrokes.

Valid MAC.png

That is of course suposed to say "Valid MAC Address?"


"Should be" isn't "Is" -Jay
0 Kudos
Message 109 of 150
(6,012 Views)

Hello,

 

I've been trying to get my head around regex but I'm stuck. Any help would be greatly appreciated.

 

I'm reading in a file as string. The string consists of blocks of data separated by markers, unfortunately not all data blocks were complete, so I have to search through the string to find complete blocks

 

A data block starts with "<-->"

A data block ends with "<xx>"

 

I want to find the first complete block in the string. So in the example below I want to return:

<-->

q

-w

e

r

<xx>

 

and I want it to ignore the incomplete block

<-->

a

s

d

 

Regex snip.PNG

 

As a bonus, if I could have every complete data block returned, that would be fantastic.

 

Thanks

David

0 Kudos
Message 110 of 150
(5,865 Views)