Match hex 00 or NULL with Match pattern function
Hi, I am using Match pattern funciton to match NULL character and 0000 character in a string (hex display).
Someone told mu use the following regular expression:
^[\00]*, and [\00]*$ , and he said:
\00 is Hex 00
\0 un-defined
But I read some stuffs about regular expression that \0x00 is Hex 00, \00 is Octal 000.I want to know what meaning the \00 is.
Please refer to the attached trim00.vi.
Solved!
Go to Solution.
Attachments:
trim00.vi 7 KB
trim00.vi 7 KB
Match Pattern and Match Regular Expression are two different functions. With Match Pattern the string ^[\00]* matches any number of null characters starting at the beginning of the string, while the string [\00]*$ matches any number of null characters starting at the end of the string. Check the help for the Match Pattern function for more info.
Mike...
Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion
"... after all, He's not a tame lion..."
Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps
Similar Messages
-
How do I use the Match Pattern Function to exclude only 0.000?
Hi,
I'm trying to use the mattch pattern function to find the first string in a table thats is >0. My table looks like:
1,0.000000,0.000 %2007/01/13 00:16:19 196281
1,0.000000,0.000 %2007/01/13 00:16:22 196282
1,0.831262,0.000 %2007/01/13 00:17:20 196375
2,0.811154,0.000 %2007/01/13 00:17:20 196375
If I us the paremeter "1,[~0]" It doesn't find the line 1,0.831262,0.000... which is the one that I want. I also tried :1,[0-9].+[~0] and that didn't work either. the problem is that the first digit after to 1, isn't allways going to go from 0 to 0.0 sometimes it might go from 0 to 2.??.
Thanks for the help
Matt"Matt361" <[email protected]> wrote in message news:[email protected]..
Hi,
I'm trying to use the mattch pattern function to find the first string in a table thats is >0. My table looks like:
1,0.000000,0.000 %2007/01/13 00:16:19 196281
1,0.000000,0.000 %2007/01/13 00:16:22 196282
1,0.831262,0.000 %2007/01/13 00:17:20 196375
2,0.811154,0.000 %2007/01/13 00:17:20 196375
If I us the paremeter "1,[~0]" It doesn't find the line 1,0.831262,0.000... which is the one that I want. I also tried :1,[0-9].+[~0] and that didn't work either. the problem is that the first digit after to 1, isn't allways going to go from 0 to 0.0 sometimes it might go from 0 to 2.??.
Thanks for the help
Matt
Hi,
1,[~0] matches a "1" a "," and then any character that is not "0".
1,[0-9].+[~0] matches a "1" a "," and then any character that is "0-9", any number of anything!! (1 or more) and then anything that is not "0". Note that you have to escape a . to match a ".". Like this "\.".
There is no way to check if there is anything other then a "0" in the match, from within the match pattern function. So I think you won't be able to find a pattern that does the trick.
Why not use a whileloop to find the first item? Or use the Spreadsheet String To Array, and then compare the desired row or column with the string "0.000000"? (Or replace all ,0.000000, by a string like ",NULL,", then match the pattern?)
In LabVIEW 8 there is a new Match Regular Expression function. Haven't tried it, but it should be much more powerfull then the Match Pattern function. But also much more complex.
Regards,
Wiebe. -
Split a string using Match Pattern function
I am trying to split a response string from a climate chamber into different parts. The string goes something like this: 0030.0\s0034.6\s0080.0\s0083.4. I am using the match pattern function to split the string using \s as the search string. But it is not splitting the string as required. If I use only \ , its working fine. Can anyone please suggest why \s is not being recognised as a part of the input string?
Subhro.
Solved!
Go to Solution.Is the string you show in normal display mode or in \ codes display mode?
Anyway, if you need to match a '\' character you'll have to mask it using \, so the match string would be '\\s' to match '\s'.
Alternatively you could use spreadsheet string to array with the correct delimiter. For the data you show this would work perfectly. -
Bank statement upload - change posting rule with search pattern function
Hi Experts,
I am trying to set up electronic bank statement. When clearing customer accounts I have some cases where the posting rule should be changed.
I have for example the following text somewhere in the reference field:
CASHPOOL.
If found, I would like the posting rule changed so only GL-area is posted and not a clearing on customer account required.
I set this up in the search pattern
C > G
A > L
S > 0
H > 1
P
O
O
L
GL01 is the posting rule, that only posts area 1.
I have assigned this pattern to the specific external code and also activated it. In the simulation function in the definition of the pattern I get the result (2 hits).
However, when reading the statement (FF_5) nothing is changed and also in simulation transaction FEBSTS or in statement post-processing I do not see anything.
Does anyone know whether I could get around this with the search pattern functionality here? What and how would I need to set it up to cover those case as above?
Any help much appreciated.
Thanks + Regards
HeinHi Shannon,
we have assigned the search string as well as the external transaction in global EBS settings to 031 algorithm`(customer from document nubmer), as in normal cases customer invoices are to be cleared here and this is working fine.
For this search pattern here with GL01 we would like to change the rule.
However, my tests with statement does not work for that. The rule stays as is.
So, from your words I read that I need to have here a second rule that changes the algorithm? Is this possible, what would I need to set so the original use is still working out (that customer items are cleared).
Tanks + Regards
Hein -
Hi, I want to extract the space (sometimes, !#" etc) from "@020 12345' using match pattern function.
When I used [\s!#"] as a regular expression, the result "20".
Why my expression is not worked and Can you propose more suitable expression?
labmaster
*)Enclosed is the VI example in LV2009
Solved!
Go to Solution.
Attachments:
yahoo.vi 7 KBlabmaster wrote:
Hi, I want to extract the space (sometimes, !#" etc) from "@020 12345' using match pattern function.
You should also describe what you mean by "extract". If you simply need a space, you can use a space diagram constant. No need to extract it. Do you want the resulting string without the space, for example?
I am sure one of the regex gurus here will jump right on this one...
LabVIEW Champion . Do more with less code and in less time . -
Regular Expression for Match Pattern (string) Function
I need to find a variable length string enclosed by brackets and
within a string. Can't seem to get the regular expression right for
the Match Pattern function. I'm able to get the job done using the
Token function, but it's not as slick or tight as I'd like. Does
anybody out there have the expression for this?Jean-Pierre Drolet wrote in message news:<[email protected]>...
> The regular expression is "\[[~\]]*\]" which means:
> look for a bracket "\[" (\ is the escape char)
> followed by a string not containing a closing bracket "[~\]]*"
> followed by a closing bracket "\]". The match string include the
> brackets
>
> You can also read "Scan from String" with the following format:
> "%[^\[]\[%[^\[\]]" and read the 2nd output. The brackets are removed
> from the scanned string.
Thanks, Jean_Pierre
I did some more experimenting after posting and found that \[.*\] also
works with the match pattern function. Thanks for your input.
sm -
Match pattern: change regular expression search via front panel?
Hello,
I have an application that I am developing which is making use of Serial VISA.
I am scanning the output of a serial port which is constantly spitting out a long string of data.
Data is being pulled from the string with several combinations of SCAN FROM STRING functions and MATCH PATTERN Functions.
Question:
How can I use a button or TEXT box on the FRONT PANEL that can change the MATCH PATTERN Functions Regular expression?
for example the string may spit out the following:
Weight\s\s\s\s\s\s\s\s\s\s\s\s-0.00\slb\s\s\s\s\s\s-16\sbits\s+74.40\s\B0F\sCorrected\s\s\s\s\s\s-0.00\slb\s+0.999987\s%\s\r
in this case the serial device is spitting out data in LB.
It could be possible for the device to spit out data in KG ... thus I need to change the REGULAR EXPRESSION.
Thank you for your timeHi,
just a quick example.
there are other way of doing this but I think the ComboBox is quite an easy one.
hope this helps
When my feet touch the ground each morning the devil thinks "bloody hell... He's up again!"
Attachments:
ComboBox.vi 12 KB -
"Match Regular Expression" and "Match Pattern" vi's behave differently
Hi,
I have a simple string matching need and by experimenting found that the "Match Regular Expression" and "Match Pattern" vi's behave somewhat differently. I'd assume that the regular expression inputs on both would behave the same. A difference I've discovered is that the "|" character (the "vertical bar" character, commonly used as an "or" operator) is recognized as such in the Match Regular Expression vi, but not in the Match Pattern vi (where it is taken literally). Furthermore, I cannot find any documentation in Help (on-line or in LabVIEW) about the "|" character usage in regular expressions. Is this documented anywhere?
For example, suppose I want to match any of the following 4 words: "The" or "quick" or "brown" or "fox". The regular expression "The|quick|brown|fox" (without the quotes) works for the Match Regular Expression vi but not the Match Pattern vi. Below is a picture of the block diagram and the front panel results:
The Help says that the Match Regular Expression vi performs somewhat slower than the Match Pattern vi, so I started with the latter. But since it doesn't work for me, I'll use the former. But does anyone have any idea of the speed difference? I'd assume it is negligible in such a simple example.
Thanks!
Solved!
Go to Solution.Yep-
You hit a point that's frustrated me a time or two as well (and incidentally, caused some hair-pulling that I can ill afford)
The hint is in the help file:
for Match regular expression "The Match Regular Expression function gives you more options for matching
strings but performs more slowly than the Match Pattern function....Use regular
expressions in this function to refine searches....
Characters to Find
Regular Expression
VOLTS
VOLTS
A plus sign or a minus sign
[+-]
A sequence of one or more digits
[0-9]+
Zero or more spaces
\s* or * (that is, a space followed by an asterisk)
One or more spaces, tabs, new lines, or carriage returns
[\t \r \n \s]+
One or more characters other than digits
[^0-9]+
The word Level only if it
appears at the beginning of the string
^Level
The word Volts only if it
appears at the end of the string
Volts$
The longest string within parentheses
The first string within parentheses but not containing any
parentheses within it
\([^()]*\)
A left bracket
A right bracket
cat, cag, cot, cog, dat, dag, dot, and dag
[cd][ao][tg]
cat or dog
cat|dog
dog, cat
dog, cat cat dog,cat
cat cat dog, and so on
((cat )*dog)
One or more of the letter a
followed by a space and the same number of the letter a, that is, a a, aa aa, aaa aaa, and so
on
(a+) \1
For Match Pattern "This function is similar to the Search and Replace
Pattern VI. The Match Pattern function gives you fewer options for matching
strings but performs more quickly than the Match Regular Expression
function. For example, the Match Pattern function does not support the
parenthesis or vertical bar (|) characters.
Characters to Find
Regular Expression
VOLTS
VOLTS
All uppercase and lowercase versions of volts, that is, VOLTS, Volts, volts, and so on
[Vv][Oo][Ll][Tt][Ss]
A space, a plus sign, or a minus sign
[+-]
A sequence of one or more digits
[0-9]+
Zero or more spaces
\s* or * (that is, a space followed by an asterisk)
One or more spaces, tabs, new lines, or carriage returns
[\t \r \n \s]+
One or more characters other than digits
[~0-9]+
The word Level only if it begins
at the offset position in the string
^Level
The word Volts only if it
appears at the end of the string
Volts$
The longest string within parentheses
The longest string within parentheses but not containing any
parentheses within it
([~()]*)
A left bracket
A right bracket
cat, dog, cot, dot, cog, and so on.
[cd][ao][tg]
Frustrating- but still managable.
Jeff -
Match Pattern does not function properly when searching for a null character
I'm using Match Pattern to extract a null terminated string from a response I'm getting from a device on a serial port. The VI is attached and below is a screenshot of the block diagram.
It works just fine with index set to 0, 1, or 2. When index is 3, I get the output shown below.
Why is Match Pattern not finding the null character?
Thanks!
Solved!
Go to Solution.
Attachments:
Grab Nullterm String.vi 15 KBI'm a dope, need to remove the wire from the Offset control to the Match Pattern control.
DUH! -
LV 7.1 VI with match pattern fails in LV8
I am seeing something weird with LabVIEW 8. Attached
is a VI that was developed in 7.1 and has been working for the past year and a
half. When I upgraded to 8.0 it started exhibiting weird behavior.
The very first time it is executed it works fine. All subsequent
executions fail. The problem is that the match pattern VI only matches
the search string the first time it is executed, after that the offset past
match is always -1. Why?
If I start from scratch in LabVIEW 8 and recreate this VI it seems to work
fine.
Joshua
Attachments:
Read_RCG_File.zip 21 KBThanks for looking at this for me. Now that you have pointed out
that the Request Deallocation was causing the problem I need to correct
what said in my original post. If I recreate the VI from scratch
in LabVIEW 8 there is still a problem. The first time I recreated
it I neglected to add the Request Deallocation.
Thanks again for your help.
Joshua
PS This VI is simplier and duplicates the problem.
Attachments:
MatchPatternDeallocateBug.vi 9 KB -
Lazy (not greedy) match pattern
Hello
I want to use match pattern to return every substring enclosed between 7E characters in a hexadecimal string.
The string looks like this : ....7E7E ....7E7E....7E7E...
I used the following regular expressions: 7E.*7E, 7E .+ 7E, 7E .+?7E but they return nothing or they return the maximum match possible (greedy match). (The regular expressions actually not like this because 7E is in hexadecimal representation and the other characters are not, the expressions would look like this: ~.*~, ~.+~, ~.+?~)
Is there a way to perform non-greedy matches in LabView?
Thank you for your helpHi forsaken,
what about this little sub-vi:
'data string' is your data value (without surrounding 0x7E), 'remaining string' is therest of the string (with 0x7E).
Message Edited by GerdW on 06-05-2007 04:44 PM
Best regards,
GerdW
CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
Kudos are welcome
Attachments:
match.png 2 KB -
Match Regular Expression does not match what Match Pattern does
I have read through a lot of posts about how Match Pattern does not match what Match Regular Expression will due to not processing some characters.
However, I found a problem with the other way. A simple Reg-Ex that works in Match Pattern but not Match Regular Expression.
What I have here is just an example. I want to use Match Regular Expression so I can specify some sub-matches.
The reg-ex is for: one or more non-numeric characters, a space, one or more numeric characters. At the start of the string.
How can I get this working in Match Regular Expression? I am working in LabVIEW 2010f2 32 bit. Here is the code snippet and the results:
Rob
Solved!
Go to Solution.Robert Cole wrote:
I think I prefer the ~ for negation since ^ is also used for beginning of the string. But we work with what we have.
Let me offer you a tip and perhaps defend the honor of the regex a little bit. One of my favorite features of regexes is the ability to specify character classes (and their negation). One of the reasons I have to think about the ~ versus ^ is that I rarely use ^ in a regex alternative.
Some examples:
[0-9] = \d (digit)
[^0-9] = \D (not a digit)
The equivalent regex for your case is: \D+ \d+ -
ZenWSBrowser"No User object matches pattern..." Intermittently works
Hi,
I have configured a few of our Helpdesk users to use the ZenWsBrowser
utility instead of ConsoleOne. They will open the utility and do a
search on "users." Lately and intermittently the ZenWsBrowser search
fails with the error below:
No User Object matches pattern 'username' could be found below container
'[Root]'!
I cannot figure out why it sometimes works and sometimes does not.
Any ideas?
Thank you,
TroyMr,
It appears that in the past few days you have not received a response to your
posting. That concerns us, and has triggered this automated reply.
Has your problem been resolved? If not, you might try one of the following options:
- Visit http://support.novell.com and search the knowledgebase and/or check all
the other self support options and support programs available.
- You could also try posting your message again. Make sure it is posted in the
correct newsgroup. (http://forums.novell.com)
Be sure to read the forum FAQ about what to expect in the way of responses:
http://forums.novell.com/faq.php
If this is a reply to a duplicate posting, please ignore and accept our apologies
and rest assured we will issue a stern reprimand to our posting bot.
Good luck!
Your Novell Product Support Forums Team
http://support.novell.com/forums/ -
Searching and Matching - Difference between 'Match Pattern' and 'Match Geometric Pattern'?
I was wondering if someone can explain to me the difference between 'Match Pattern' and 'Match Geometric Pattern' VIs? I'm really not sure which best to use for my application. I'm trying to search/match small spherical particles in a grey video in order to track their speed (I'm doing this after subtracting two subsequent frames to get rid of background motion artifacts).
Which should I use?
Thank you!
Solved!
Go to Solution.Hi TKassis,
1.You may find from this link for the difference between these two,
Pattern Match : http://zone.ni.com/reference/en-XX/help/370281P-01/imaqvision/imaq_match_pattern_3/
Geometric Match : http://zone.ni.com/reference/en-XX/help/370281P-01/imaqvision/imaq_match_geometric_pattern/.
2. I always prefer match pattern because of its execution speed, and incase of geometric pattern match it took lot of time to match your result. You may find in the attached figure for same image with these two algorithm execution time.
Sasi.
Certified LabVIEW Associate Developer
If you can DREAM it, You can DO it - Walt Disney -
Java Pattern Matcher (Pattern.class bug? Stuck in Infinite Loop)
Hi,
I'm using the java pattern matcher and it appears to be stuck in an infinite loop and will not return from Pattern.class.
It stays stuck in the following two code sequences...
I'm using the following regex...
java.util.regex.Matcher[pattern=[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+(?:[A-Z]{2}|com|org|net|biz|info) region=0,353648 lastmatch=
MAIN BLOCK STUCK IN LOOP:
boolean study(TreeInfo info) {
if (type != INDEPENDENT) {
int minL = info.minLength;
atom.study(info);
info.minLength = minL;
info.deterministic = false;
return next.study(info);
} else {
atom.study(info);
return next.study(info);
SECOND BLOCK STUCK IN LOOP:
boolean match(Matcher matcher, int i, CharSequence seq) {
// Check for zero length group
if (i > matcher.locals[beginIndex]) {
int count = matcher.locals[countIndex];
if (count < cmin) {
matcher.locals[countIndex] = count + 1;
boolean result = body.match(matcher, i, seq);
// If match failed we must backtrack, so
// the loop count should NOT be incremented
if (!result)
matcher.locals[countIndex] = count;
return result;
if (next.match(matcher, i, seq))
return true;
if (count < cmax) {
matcher.locals[countIndex] = count + 1;
boolean result = body.match(matcher, i, seq);
// If match failed we must backtrack, so
// the loop count should NOT be incremented
if (!result)
matcher.locals[countIndex] = count;
return result;
return false;
return next.match(matcher, i, seq);
Is this a bug with the Java 1.6 Pattern Matcher?
Thanks
V$h3rThe Java Pattern Matcher is getting stuck in the following code...
boolean study(TreeInfo info) {
if (type != INDEPENDENT) {
int minL = info.minLength;
atom.study(info);
info.minLength = minL;
info.deterministic = false;
return next.study(info);
} else {
atom.study(info);
return next.study(info);
boolean match(Matcher matcher, int i, CharSequence seq) {
// Check for zero length group
if (i > matcher.locals[beginIndex]) {
int count = matcher.locals[countIndex];
if (count < cmin) {
matcher.locals[countIndex] = count 1;
boolean result = body.match(matcher, i, seq);
// If match failed we must backtrack, so
// the loop count should NOT be incremented
if (!result)
matcher.locals[countIndex] = count;
return result;
if (next.match(matcher, i, seq))
return true;
if (count < cmax) {
matcher.locals[countIndex] = count + 1;
boolean result = body.match(matcher, i, seq);
// If match failed we must backtrack, so
// the loop count should NOT be incremented
if (!result)
matcher.locals[countIndex] = count;
return result;
return false;
return next.match(matcher, i, seq);
}Here is a copy of the REGEX that I'm using...
It works on most of the other STRINGS but when I do a REGEX on the the html source for http://www.exponent.com it will get stuck...
Pattern p = Pattern.compile("[a-zA-Z0-9+_~-]+(?:\\.[a-zA-Z0-9+_~-]+)*@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\\.)+(?:com|org|net|biz|info|[a-zA-Z]{2})");Thanks,
V$h3r
Maybe you are looking for
-
When ever i put in a dvd it just ejects it with no message, no nothing. But it will play only certain ones with no problem. What could it be?
-
I looked at my 'extras & info' in settings and Amber Update was in bright yellow, bold text. I went to me phone update and it keeps saying my phone is up to date. I tried turning my phone on and off but it keeps saying my phone is up to date even tho
-
Huge volume of records are routing to the remote user other than his position and organization records. Synchronization and DB initialization taking more time around 36 hours. Actual accounts & contacts need to be route around 2000 & 3000 but we have
-
How can i get my 3G to tether to my laptop?
I am in the US and use ATT . But I cannot see the tethering setting on my phone
-
What's up with those lines?
Hey all, I've been getting these lines in my moving images. Not so much when things are relatively still. Or sometimes when I capture a still frame from one of my clips. I've tried to capture an example to show you but haven't figured out how. I swea