BreakPoint

cancel
Showing results for 
Search instead for 
Did you mean: 

Regular Expressions Board

Hi,

 

I was just reading through this discussion and would be happy if you could tell me how to write a string code to the regular expression match to extract the time stamp from an sms text message. My string input is the following:

at+cmgr=1\r\r\n+CMGR:\s"REC\sREAD","+447891089303",,"11/02/24,14:29:32+00"\r\nIT:26.102/IB:11.964/OU:0FL:360.98\s\r\n\r\nOK\r\n.

 

Regards,

 

Hammy.

Message 31 of 150
(11,482 Views)

\d\d/\d\d/\d\d,\d\d:\d\d:\d\d

 

Does this get what you're after?  11/02/24,14:29:32

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

Message 32 of 150
(11,476 Views)

Ever have a need to replace large blocks of ASCII hex with the binary equivalents? This code snippet does just that. It actually looks for the string <HEX: xxxx xxxx xxxx xxxx> and replaces that with the binary data. This works over large blocks of text and will work if the data is split between chunks. For example, if you are reading a large file in chunks and converting the data on the fly. It would be trivial to modifiy the delimiter that defines the block to be converted. This is useful if you have a hex dump saved in an ASCII file and you need to convert it.

 

Hex Replacement.png



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Download All
Message 33 of 150
(11,455 Views)

Thanks Mark,

 

Here's a simple regEx to remove all <tags> from a string.

 

Message 34 of 150
(11,365 Views)

Any suggestions on how I could improve this Scan From String? (or maybe use some other function)

All I need is the two numeric values (doubles).  I do not care about the leading text (as shown)

 

I was trying to accomplish it by just extracting the numeric values...

 

-regEx NooB-

 

 

Message 35 of 150
(11,328 Views)

 


@Ray.R wrote:

Any suggestions on how I could improve this Scan From String? (or maybe use some other function)

All I need is the two numeric values (doubles).  I do not care about the leading text (as shown)

 

I was trying to accomplish it by just extracting the numeric values...

 

-regEx NooB-

 

 


 

Try this:

Extract Floating Point Numbers.png

 

You may need to play with the regular expression if your numbers can come back without the decimal point. You will also need to convert the strings to numbers.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 36 of 150
(11,318 Views)

Here is a common construct I use to extract numbers from a string.

 

ExtractNumbers.png

Message 37 of 150
(11,307 Views)

This one is from jcarmody on this thread

 

http://forums.ni.com/t5/LabVIEW/Different-fonts-in-string-indicator/td-p/1601458

 

He helps someone change color on a string indicator using > or < to determine color.

 

original.png

Tim
GHSP
0 Kudos
Message 38 of 150
(11,229 Views)

This one is from Ray R on this thread:

 

http://forums.ni.com/t5/LabVIEW/regular-exp/td-p/1662386

 

regExGetNumbers.png

Tim
GHSP
0 Kudos
Message 39 of 150
(11,171 Views)

and the improved version from Jim:

 

0 Kudos
Message 40 of 150
(11,155 Views)