06-05-2013 10:21 AM - edited 06-05-2013 10:22 AM
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..
06-05-2013 10:38 AM - edited 06-05-2013 10:45 AM
(\D+)(?:\[?([^\]]+)])?\s
06-05-2013 11:14 AM - edited 06-05-2013 11:15 AM
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.
06-07-2013 09:41 AM
British or American version?
06-09-2013 02:37 PM
There's an American version??!!?? 😮
06-10-2013 03:31 AM
@Ray.R wrote:
There's an American version??!!?? 😮
Shh. We don't talk about that one.....
06-14-2013 08:12 AM
06-14-2013 08:14 AM
@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!
06-14-2013 03:51 PM - edited 06-14-2013 03:59 PM
Just to see how big my eyes get when some of you get ahold of this and manage it with about 2 keystrokes.
That is of course suposed to say "Valid MAC Address?"
09-24-2013 09:20 AM
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
As a bonus, if I could have every complete data block returned, that would be fantastic.
Thanks
David