Question about match regular expression
Colleagues,
Very stupid question. I would like to get substring between "..." symbols. For example, string 02 July from Explosion occurred on "02 July", 2008.
How to do this with single Match Regular Expression?
For example such expression ".*" will give me "02 July":
But I would like to get it without " symbols!
I tried this "[~"]*" and this "[~"].*", then read this and this , and all without success... But I'm sure it should be possible. Can you help me?
Andrey.
PS
This regular expression should give exactly the same output as following construction:
I'm only using 7.0 now, but you can do this with Scan from String...
%[^"]"%[^"]"%[^"]
Message Edited by Phillip Brooks on 07-02-2008 02:47 PM
Now is the right time to use %^<%Y-%m-%dT%H:%M:%S%3uZ>T
If you don't hate time zones, you're not a real programmer.
"You are what you don't automate"
Inplaceness is synonymous with insidiousness
Attachments:
NotPCRE.png 20 KB
Similar Messages
-
A question about using regular expression
Hi,
This is a part of HTML file.
<SPAN>how</span>
<SPAN>are</span>
<SPAN>you</span>
I want to search string between each pair of <SPAN> , </SPAN> tags by using Regular Expression.
For example:
how
are
you
If I use following method
String regx="<SPAN>(.+)<SPAN>";
Matcher m=Pattern.compile(regx).matcher(str);
int currentLoc=0;
while(currentLoc<str.length()){
if(m.find(currentLoc))
System.out.println(m.group(1));
currentLoc=m.end();
}The content between first <SPAN> and last </SPAN> will be searched.
How to solve this problem?Use a non-greedy match:
(?s)<SPAN>(.+?)<SPAN>(?s) makes the dot match the line terminator (same as setting the dot all option) -
Question about creating regular expression
Hi!
I am creating parser for the specific configuration file. Now I have got small problem: I need to find the line with text in format "key value".
For example I have this text file:
entry {
key value
key2 value2
entry2 {
}I wish to find, using java.regex, these two lines: "key value" and "key2 value2". But how?Is your problem that you don't understand regular expressions? If so then this might help. Or is your problem you don't understand Java regular expressions? If so then this might help. Or is your problem that you don't understand how to read lines of a file? If so then this might help.
-
Namburi,
When you said you used the Reg Exp tool, did you use it only as
preconfigured by the iMT migrate application wizard?
Because the default configuration of the regular expression tool will only
target the files in your ND project directories. If you wish to target
classes outside of the normal directory scope, you have to either modify the
"Source Directory" property OR create another instance of the regular
expression tool. See the "Tool" menu in the iMT to create additional tool
instances which can each be configured to target different sets of files
using different sets of rules.
Usually, I utilize 3 different sets of rules files on a given migration:
spider2jato.xml
these are the generic conversion rules (but includes the optimized rules for
ViewBean and Model based code, i.e. these rules do not utilize the
RequestManager since it is not needed for code running inside the ViewBean
or Model classes)
I run these rules against all files.
See the file download section of this forum for periodic updates to these
rules.
nonProjectFileRules.xml
these include rules that add the necessary
RequestManager.getRequestContext(). etc prefixes to many of the common
calls.
I run these rules against user module and any other classes that do not are
not ModuleServlet, ContainerView, or Model classes.
appXRules.xml
these rules include application specific changes that I discover while
working on the project. A common thing here is changing import statements
(since the migration tool moves ND project code into different jato
packaging structure, you sometime need to adjust imports in non-project
classes that previously imported ND project specific packages)
So you see, you are not limited to one set of rules at all. Just be careful
to keep track of your backups (the regexp tool provides several options in
its Expert Properties related to back up strategies).
----- Original Message -----
From: <vnamboori@y...>
Sent: Wednesday, August 08, 2001 6:08 AM
Subject: [iPlanet-JATO] Re: Use Of models in utility classes - Pease don't
forget about the regular expression potential
Thanks Matt, Mike, Todd
This is a great input for our migration. Though we used the existing
Regular Expression Mapping tool, we did not change this to meet our
own needs as mentioned by Mike.
We would certainly incorporate this to ease our migration.
Namburi
--- In iPlanet-JATO@y..., "Todd Fast" <toddwork@c...> wrote:
All--
Great response. By the way, the Regular Expression Tool uses thePerl5 RE
syntax as implemented by Apache OROMatcher. If you're doing lotsof these
sorts of migration changes manually, you should definitely buy theO'Reilly
book "Mastering Regular Expressions" and generate some rules toautomate the
conversion. Although they are definitely confusing at first,regular
expressions are fairly easy to understand with some documentation,and are
superbly effective at tackling this kind of migration task.
Todd
----- Original Message -----
From: "Mike Frisino" <Michael.Frisino@S...>
Sent: Tuesday, August 07, 2001 5:20 PM
Subject: Re: [iPlanet-JATO] Use Of models in utility classes -Pease don't
forget about the regular expression potential
Also, (and Matt's document may mention this)
Please bear in mind that this statement is not totally correct:
Since the migration tool does not do much of conversion for
these
utilities we have to do manually.Remember, the iMT is a SUITE of tools. There is the extractiontool, and
the translation tool, and the regular expression tool, and severalother
smaller tools (like the jar and compilation tools). It is correctto state
that the extraction and translation tools only significantlyconvert the
primary ND project objects (the pages, the data objects, and theproject
classes). The extraction and translation tools do minimumtranslation of the
User Module objects (i.e. they repackage the user module classes inthe new
jato module packages). It is correct that for all other utilityclasses
which are not formally part of the ND project, the extraction and
translation tools do not perform any migration.
However, the regular expression tool can "migrate" any arbitrary
file
(utility classes etc) to the degree that the regular expressionrules
correlate to the code present in the arbitrary file. So first andforemost,
if you have alot of spider code in your non-project classes youshould
consider using the regular expression tool and if warranted adding
additional rules to reduce the amount of manual adjustments thatneed to be
made. I can stress this enough. We can even help you write theregular
expression rules if you simply identify the code pattern you wish to
convert. Just because there is not already a regular expressionrule to
match your need does not mean it can't be written. We have notnearly
exhausted the possibilities.
For example if you say, we need to convert
CSpider.getDataObject("X");
To
RequestManager.getRequestContext().getModelManager().getModel(XModel.class);
Maybe we or somebody else in the list can help write that regularexpression if it has not already been written. For instance in thelast
updated spider2jato.xml file there is already aCSpider.getCommonPage("X")
rule:
<!--getPage to getViewBean-->
<mapping-rule>
<mapping-rule-primarymatch>
<![CDATA[CSpider[.\s]*getPage[\s]*\(\"([^"]*)\"]]>
</mapping-rule-primarymatch>
<mapping-rule-replacement>
<mapping-rule-match>
<![CDATA[CSpider[.\s]*getPage[\s]*\(\"([^"]*)\"]]>
</mapping-rule-match>
<mapping-rule-substitute>
<![CDATA[getViewBean($1ViewBean.class]]>
</mapping-rule-substitute>
</mapping-rule-replacement>
</mapping-rule>
Following this example a getDataObject to getModel would look
like this:
<mapping-rule>
<mapping-rule-primarymatch>
<![CDATA[CSpider[.\s]*getDataObject[\s]*\(\"([^"]*)\"]]>
</mapping-rule-primarymatch>
<mapping-rule-replacement>
<mapping-rule-match>
<![CDATA[CSpider[.\s]*getDataObject[\s]*\(\"([^"]*)\"]]>
</mapping-rule-match>
<mapping-rule-substitute>
<![CDATA[getModel($1Model.class]]>
</mapping-rule-substitute>
</mapping-rule-replacement>
</mapping-rule>
In fact, one migration developer already wrote that rule andsubmitted it
for inclusion in the basic set. I will post another upgrade to thebasic
regular expression rule set, look for a "file uploaded" posting.Also,
please consider contributing any additional generic rules that youhave
written for inclusion in the basic set.
Please not, that in some cases (Utility classes in particular)
the rule
application may be more effective as TWO sequention rules ratherthan one
monolithic rule. Again using the example above, it will convert
CSpider.getDataObject("Foo");
To
getModel(FooModel.class);
Now that is the most effective conversion for that code if that
code is in
a page or data object class file. But if that code is in a Utilityclass you
really want:
>
RequestManager.getRequestContext().getModelManager().getModel(FooModel.class
So to go from
getModel(FooModel.class);
To
RequestManager.getRequestContext().getModelManager().getModel(FooModel.class
You would apply a second rule AND you would ONLY run this rule
against
your utility classes so that you would not otherwise affect yourViewBean
and Model classes which are completely fine with the simplegetModel call.
<mapping-rule>
<mapping-rule-primarymatch>
<![CDATA[getModel\(]]>
</mapping-rule-primarymatch>
<mapping-rule-replacement>
<mapping-rule-match>
<![CDATA[getModel\(]]>
</mapping-rule-match>
<mapping-rule-substitute>
<![CDATA[RequestManager.getRequestContext().getModelManager().getModel(]]>
</mapping-rule-substitute>
</mapping-rule-replacement>
</mapping-rule>
A similer rule can be applied to getSession and other CSpider APIcalls.
For instance here is the rule for converting getSession calls toleverage
the RequestManager.
<mapping-rule>
<mapping-rule-primarymatch>
<![CDATA[getSession\(\)\.]]>
</mapping-rule-primarymatch>
<mapping-rule-replacement>
<mapping-rule-match>
<![CDATA[getSession\(\)\.]]>
</mapping-rule-match>
<mapping-rule-substitute>
<![CDATA[RequestManager.getSession().]]>
</mapping-rule-substitute>
</mapping-rule-replacement>
</mapping-rule>
----- Original Message -----
From: "Matthew Stevens" <matthew.stevens@e...>
Sent: Tuesday, August 07, 2001 12:56 PM
Subject: RE: [iPlanet-JATO] Use Of models in utility classes
Namburi,
I will post a document to the group site this evening which has
the
details
on various tactics of migrating these type of utilities.
Essentially,
you
either need to convert these utilities to Models themselves or
keep the
utilities as is and simply use the
RequestManager.getRequestContext.getModelManager().getModel()
to statically access Models.
For CSpSelect.executeImmediate() I have an example of customhelper
method
as a replacement whicch uses JDBC results instead of
CSpDBResult.
matt
-----Original Message-----
From: vnamboori@y... [mailto:<a href="/group/SunONE-JATO/post?protectID=081071113213093190112061186248100208071048">vnamboori@y...</a>]
Sent: Tuesday, August 07, 2001 3:24 PM
Subject: [iPlanet-JATO] Use Of models in utility classes
Hi All,
In the present ND project we have lots of utility classes.
These
classes in diffrent directory. Not part of nd pages.
In these classes we access the dataobjects and do themanipulations.
So we access dataobjects directly like
CSpider.getDataObject("do....");
and then execute it.
Since the migration tool does not do much of conversion forthese
utilities we have to do manually.
My question is Can we access the the models in the postmigration
sameway or do we need requestContext?
We have lots of utility classes which are DataObjectintensive. Can
someone suggest a better way to migrate this kind of code.
Thanks
Namburi
[email protected]
[email protected]
[Non-text portions of this message have been removed]
[email protected]
[email protected]Namburi,
When you said you used the Reg Exp tool, did you use it only as
preconfigured by the iMT migrate application wizard?
Because the default configuration of the regular expression tool will only
target the files in your ND project directories. If you wish to target
classes outside of the normal directory scope, you have to either modify the
"Source Directory" property OR create another instance of the regular
expression tool. See the "Tool" menu in the iMT to create additional tool
instances which can each be configured to target different sets of files
using different sets of rules.
Usually, I utilize 3 different sets of rules files on a given migration:
spider2jato.xml
these are the generic conversion rules (but includes the optimized rules for
ViewBean and Model based code, i.e. these rules do not utilize the
RequestManager since it is not needed for code running inside the ViewBean
or Model classes)
I run these rules against all files.
See the file download section of this forum for periodic updates to these
rules.
nonProjectFileRules.xml
these include rules that add the necessary
RequestManager.getRequestContext(). etc prefixes to many of the common
calls.
I run these rules against user module and any other classes that do not are
not ModuleServlet, ContainerView, or Model classes.
appXRules.xml
these rules include application specific changes that I discover while
working on the project. A common thing here is changing import statements
(since the migration tool moves ND project code into different jato
packaging structure, you sometime need to adjust imports in non-project
classes that previously imported ND project specific packages)
So you see, you are not limited to one set of rules at all. Just be careful
to keep track of your backups (the regexp tool provides several options in
its Expert Properties related to back up strategies).
----- Original Message -----
From: <vnamboori@y...>
Sent: Wednesday, August 08, 2001 6:08 AM
Subject: [iPlanet-JATO] Re: Use Of models in utility classes - Pease don't
forget about the regular expression potential
Thanks Matt, Mike, Todd
This is a great input for our migration. Though we used the existing
Regular Expression Mapping tool, we did not change this to meet our
own needs as mentioned by Mike.
We would certainly incorporate this to ease our migration.
Namburi
--- In iPlanet-JATO@y..., "Todd Fast" <toddwork@c...> wrote:
All--
Great response. By the way, the Regular Expression Tool uses thePerl5 RE
syntax as implemented by Apache OROMatcher. If you're doing lotsof these
sorts of migration changes manually, you should definitely buy theO'Reilly
book "Mastering Regular Expressions" and generate some rules toautomate the
conversion. Although they are definitely confusing at first,regular
expressions are fairly easy to understand with some documentation,and are
superbly effective at tackling this kind of migration task.
Todd
----- Original Message -----
From: "Mike Frisino" <Michael.Frisino@S...>
Sent: Tuesday, August 07, 2001 5:20 PM
Subject: Re: [iPlanet-JATO] Use Of models in utility classes -Pease don't
forget about the regular expression potential
Also, (and Matt's document may mention this)
Please bear in mind that this statement is not totally correct:
Since the migration tool does not do much of conversion for
these
utilities we have to do manually.Remember, the iMT is a SUITE of tools. There is the extractiontool, and
the translation tool, and the regular expression tool, and severalother
smaller tools (like the jar and compilation tools). It is correctto state
that the extraction and translation tools only significantlyconvert the
primary ND project objects (the pages, the data objects, and theproject
classes). The extraction and translation tools do minimumtranslation of the
User Module objects (i.e. they repackage the user module classes inthe new
jato module packages). It is correct that for all other utilityclasses
which are not formally part of the ND project, the extraction and
translation tools do not perform any migration.
However, the regular expression tool can "migrate" any arbitrary
file
(utility classes etc) to the degree that the regular expressionrules
correlate to the code present in the arbitrary file. So first andforemost,
if you have alot of spider code in your non-project classes youshould
consider using the regular expression tool and if warranted adding
additional rules to reduce the amount of manual adjustments thatneed to be
made. I can stress this enough. We can even help you write theregular
expression rules if you simply identify the code pattern you wish to
convert. Just because there is not already a regular expressionrule to
match your need does not mean it can't be written. We have notnearly
exhausted the possibilities.
For example if you say, we need to convert
CSpider.getDataObject("X");
To
RequestManager.getRequestContext().getModelManager().getModel(XModel.class);
Maybe we or somebody else in the list can help write that regularexpression if it has not already been written. For instance in thelast
updated spider2jato.xml file there is already aCSpider.getCommonPage("X")
rule:
<!--getPage to getViewBean-->
<mapping-rule>
<mapping-rule-primarymatch>
<![CDATA[CSpider[.\s]*getPage[\s]*\(\"([^"]*)\"]]>
</mapping-rule-primarymatch>
<mapping-rule-replacement>
<mapping-rule-match>
<![CDATA[CSpider[.\s]*getPage[\s]*\(\"([^"]*)\"]]>
</mapping-rule-match>
<mapping-rule-substitute>
<![CDATA[getViewBean($1ViewBean.class]]>
</mapping-rule-substitute>
</mapping-rule-replacement>
</mapping-rule>
Following this example a getDataObject to getModel would look
like this:
<mapping-rule>
<mapping-rule-primarymatch>
<![CDATA[CSpider[.\s]*getDataObject[\s]*\(\"([^"]*)\"]]>
</mapping-rule-primarymatch>
<mapping-rule-replacement>
<mapping-rule-match>
<![CDATA[CSpider[.\s]*getDataObject[\s]*\(\"([^"]*)\"]]>
</mapping-rule-match>
<mapping-rule-substitute>
<![CDATA[getModel($1Model.class]]>
</mapping-rule-substitute>
</mapping-rule-replacement>
</mapping-rule>
In fact, one migration developer already wrote that rule andsubmitted it
for inclusion in the basic set. I will post another upgrade to thebasic
regular expression rule set, look for a "file uploaded" posting.Also,
please consider contributing any additional generic rules that youhave
written for inclusion in the basic set.
Please not, that in some cases (Utility classes in particular)
the rule
application may be more effective as TWO sequention rules ratherthan one
monolithic rule. Again using the example above, it will convert
CSpider.getDataObject("Foo");
To
getModel(FooModel.class);
Now that is the most effective conversion for that code if that
code is in
a page or data object class file. But if that code is in a Utilityclass you
really want:
>
RequestManager.getRequestContext().getModelManager().getModel(FooModel.class
So to go from
getModel(FooModel.class);
To
RequestManager.getRequestContext().getModelManager().getModel(FooModel.class
You would apply a second rule AND you would ONLY run this rule
against
your utility classes so that you would not otherwise affect yourViewBean
and Model classes which are completely fine with the simplegetModel call.
<mapping-rule>
<mapping-rule-primarymatch>
<![CDATA[getModel\(]]>
</mapping-rule-primarymatch>
<mapping-rule-replacement>
<mapping-rule-match>
<![CDATA[getModel\(]]>
</mapping-rule-match>
<mapping-rule-substitute>
<![CDATA[RequestManager.getRequestContext().getModelManager().getModel(]]>
</mapping-rule-substitute>
</mapping-rule-replacement>
</mapping-rule>
A similer rule can be applied to getSession and other CSpider APIcalls.
For instance here is the rule for converting getSession calls toleverage
the RequestManager.
<mapping-rule>
<mapping-rule-primarymatch>
<![CDATA[getSession\(\)\.]]>
</mapping-rule-primarymatch>
<mapping-rule-replacement>
<mapping-rule-match>
<![CDATA[getSession\(\)\.]]>
</mapping-rule-match>
<mapping-rule-substitute>
<![CDATA[RequestManager.getSession().]]>
</mapping-rule-substitute>
</mapping-rule-replacement>
</mapping-rule>
----- Original Message -----
From: "Matthew Stevens" <matthew.stevens@e...>
Sent: Tuesday, August 07, 2001 12:56 PM
Subject: RE: [iPlanet-JATO] Use Of models in utility classes
Namburi,
I will post a document to the group site this evening which has
the
details
on various tactics of migrating these type of utilities.
Essentially,
you
either need to convert these utilities to Models themselves or
keep the
utilities as is and simply use the
RequestManager.getRequestContext.getModelManager().getModel()
to statically access Models.
For CSpSelect.executeImmediate() I have an example of customhelper
method
as a replacement whicch uses JDBC results instead of
CSpDBResult.
matt
-----Original Message-----
From: vnamboori@y... [mailto:<a href="/group/SunONE-JATO/post?protectID=081071113213093190112061186248100208071048">vnamboori@y...</a>]
Sent: Tuesday, August 07, 2001 3:24 PM
Subject: [iPlanet-JATO] Use Of models in utility classes
Hi All,
In the present ND project we have lots of utility classes.
These
classes in diffrent directory. Not part of nd pages.
In these classes we access the dataobjects and do themanipulations.
So we access dataobjects directly like
CSpider.getDataObject("do....");
and then execute it.
Since the migration tool does not do much of conversion forthese
utilities we have to do manually.
My question is Can we access the the models in the postmigration
sameway or do we need requestContext?
We have lots of utility classes which are DataObjectintensive. Can
someone suggest a better way to migrate this kind of code.
Thanks
Namburi
[email protected]
[email protected]
[Non-text portions of this message have been removed]
[email protected]
[email protected] -
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+ -
Match Regular Expression not returning submatches.
I am having an issue with Match Regular Expression not returning the appropriate number of submatches. My string is as follows:
DATAM 995000 1.75 0.007 -67.47 24.493 99.072
The spaces are tabs and the length is not fixed so simple string manipulation is out of the question. The regular expression I was trying is as follows:
(?<=\t)[0-9\.\-]*(?=(\t|$))
It successfully returns Whole Match as the first number but no submatches are returned. I've tried simpler expressions which work in Matlab and EditPad Pro such as [0-9.-]* but never got the same answer in Labview.
What is going on?Here is an image of the VI. The top portion is the input from our Licor 7000. The bottom portion is the bit of code I'm having problems with.
Attachments:
matchregularexpression.jpg 336 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 -
Matching Regular Expressions in OBPM 10GR3
Hi all,
How do I match Regular expressions like" Wait For Response" in Strings using OBPM?
Any idea?
Is there any exact syntax?
Because I tried doing this:-
for( int i=0; i < testGroup.length(); i++)
if(testGroup.reason.match(regexp : "Wait For Response"))
logMessage("--Test Group Matched--");
But it does not work..
Any idea?String myVar = "has matching_char_set";
if ( myVar.match(regexp : '/matching_char_set/') ) {
logMessage("matched...yep");
Try like this ..should work.
Rgds,
Biltu -
Multi-line String - Match Regular Expression
I am trying to figure out the format of a regular expression in order to pull select lines out of a multi-line string and populate those lines as individual elements of a string array while using Match Regular Expression. The overall length of the multi-line string can vary as well as the text contained within the string. The string can contain letters, numbers, and special characters. I have attached an example VI. Within the example VI I only want to return the lines beginning with "Device #" into the array. The number of lines beginning with "Device #" can vary but I want to capture them all.
Or is there a better function to use instead of Match Regular Expression that will give me the desired outcome?
Solved!
Go to Solution.
Attachments:
MultiLine Regular Expression.vi 22 KBaaronb wrote:
I am trying to figure out the format of a regular expression in order to pull select lines out of a multi-line string and populate those lines as individual elements of a string array while using Match Regular Expression. The overall length of the multi-line string can vary as well as the text contained within the string. The string can contain letters, numbers, and special characters. I have attached an example VI. Within the example VI I only want to return the lines beginning with "Device #" into the array. The number of lines beginning with "Device #" can vary but I want to capture them all.
Or is there a better function to use instead of Match Regular Expression that will give me the desired outcome?
Match Regular Expression works well for this.
Ben64 -
Match Regular Expression Function input string format
Hi,
I am new to labview and was having some difficulties using the Match Regular Experssion Function.
I am using labview to communicate with a sensor. I have installed the NI device driver to do so. The output of my sensor is in the format,
X20
R40 P20 A123. The numbers in this case are arbitrary. I am trying to use Match Regular Expression Function to display and perform mathematical operations on the numbers. I am having difficulties formatting the input string on the Match Regular Expression Function. Could you please give me some tips on how to format the example I provided.
ThankMoAgha wrote:
Hi,
I am new to labview and was having some difficulties using the Match Regular Experssion Function.
I am using labview to communicate with a sensor. I have installed the NI device driver to do so. The output of my sensor is in the format,
X20
R40 P20 A123. The numbers in this case are arbitrary. I am trying to use Match Regular Expression Function to display and perform mathematical operations on the numbers. I am having difficulties formatting the input string on the Match Regular Expression Function. Could you please give me some tips on how to format the example I provided.
Thank
Here is a way to do it if the format is constant (X R P A followed by a positive integer number).
Ben64 -
Parse Mac Address with match regular expression
Hi Everyone,
I have a problem with the Match Regular Expression function,
I am trying to parse the response two a arp -a 192.168.0.15 request in order to extract MAC address of this remote IP, I used the following RegEx: ^([0-9a-fA-F]{2}[:-]){5}([0-9a-fA-F]{2})$
I am wondering why do I need to do a string subset first to extract only the MAC Address part. Isn't Match Regular Expression function capable of recognizing the RegEx directly in the middle of a string?
I only works when I extract the right tring subset as in the picture bellow.
Thanks for your answers.
Solved!
Go to Solution.
Attachments:
Mac Address.JPG 40 KBGet rid of the "^" in the beginning of your regular expression. You are instructing it to find the pattern at the beginning of the string.
Mark Yedinak
"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot -
Few questions about Airport Extreme/Express
I have a few questions about Airport extreme/express:
1 Can you access hard drive trough express?
2 I have cable NOT wireless modem. What would be the best option (speed-wise) to connect to internet- connect modem to Extreme and access internet wirelessly from it? To connect modem to Extreme and imac?
3 How fast is read/ write from hard drive connected to Extreme?
4 How many hard drives can you connect to Extreme (or Express if that is possible)?
5 Can you remotely sync Ipod nano/ shuffle using Extreme?
I really hate wire clutter around my desk. What I intend to do is to connect hard drives and printer to Airport Extreme and access them remotely. That would leave empty desk:).
Thanks1. You cannot connect a hard drive to the Airport Express USB port.
2. The speed of wireless networking is faster than the speed of most cable internet services. Therefore, you won't notice any difference in your internet connection speed between (a) a cabled connection directly between Mac and modem or (b) a wireless connection between Mac and base station and modem.
3. Apple has not published any specs on the speed of hard drive access for the Airport Extreme N Base Station. Several people have posted their own measurements (do a search in this discussion forum), and generally those results are not very good.
4. Apple has not placed a limit on the number of drives you can attach to the Airport Extreme N Base Station (with use of a hub). How many do you want to connect?
5. You cannot remotely sync an iPod using the Extreme Base Station. -
Pattern matching regular expressions
I'm attempting to determine if a string matches a pattern of containing less than 100 alphanumeric characters a-z or 0-9 case insensitive. So my regular expression string looks like:
"^[a-zA-Z0-9]{0,100}$"And I use something like...
Pattern pattern = Pattern.compile( regexString );I'd like to modify my regex string to include the email 'at' symbol "@". So that the at symbol will be allowed. But my understanding of regex is very limited. How do I include an "or at symbol" in my regex expression?
Thanks for your help.* Code by sabre150
private static final Pattern emailMatcher;
static
// Build up the regular expression according to RFC821
// http://www.ietf.org/rfc/rfc0821.txt
// <x> ::= any one of the 128 ASCII characters (no exceptions)
String x_ = "\u0000-\u007f";
// <special> ::= "<" | ">" | "(" | ")" | "[" | "]" | "\" | "."
// | "," | ";" | ":" | "@" """ | the control
// characters (ASCII codes 0 through 31 inclusive and
// 127)
String special_ = "<>()\\[\\]\\\\\\.,;:@\"\u0000-\u001f\u007f";
// <c> ::= any one of the 128 ASCII characters, but not any
// <special> or <SP>
String c_ = "[" + x_ + "&&" + "[^" + special_ + "]&&[^ ]]";
// <char> ::= <c> | "\" <x>
String char_ = "(?:" + c_ + "|\\\\[" + x_ + "])";
// <string> ::= <char> | <char> <string>
String string_ = char_ + "+";
// <dot-string> ::= <string> | <string> "." <dot-string>
String dot_string_ = string_ + "(?:\\." + string_ + ")*";
// <q> ::= any one of the 128 ASCII characters except <CR>,
// <LF>, quote ("), or backslash (\)
String q_ = "["+x_+"$$[^\r\n\"\\\\]]";
// <qtext> ::= "\" <x> | "\" <x> <qtext> | <q> | <q> <qtext>
String qtext_ = "(?:\\\\[" + x_ + "]|" + q_ + ")+";
// <quoted-string> ::= """ <qtext> """
String quoted_string_ = "\"" + qtext_ + "\"";
// <local-part> ::= <dot-string> | <quoted-string>
String local_part_ = "(?:(?:" + dot_string_ + ")|(?:" + quoted_string_ + "))";
// <a> ::= any one of the 52 alphabetic characters A through Z
// in upper case and a through z in lower case
String a_ = "[a-zA-Z]";
// <d> ::= any one of the ten digits 0 through 9
String d_ = "[0-9]";
// <let-dig> ::= <a> | <d>
String let_dig_ = "[" + a_ + d_ + "]";
// <let-dig-hyp> ::= <a> | <d> | "-"
String let_dig_hyp_ = "[-" + a_ + d_ + "]";
// <ldh-str> ::= <let-dig-hyp> | <let-dig-hyp> <ldh-str>
// String ldh_str_ = let_dig_hyp_ + "+";
// RFC821 looks wrong since the production "<name> ::= <a> <ldh-str> <let-dig>"
// forces a name to have at least 3 characters and country codes such as
// uk,ca etc would be illegal! I shall change this to make the
// second term of <name> optional by make a zero length ldh-str allowable.
String ldh_str_ = let_dig_hyp_ + "*";
// <name> ::= <a> <ldh-str> <let-dig>
String name_ = "(?:" + a_ + ldh_str_ + let_dig_ + ")";
// <number> ::= <d> | <d> <number>
String number_ = d_ + "+";
// <snum> ::= one, two, or three digits representing a decimal
// integer value in the range 0 through 255
String snum_ = "(?:[01]?[0-9]{2}|2[0-4][0-9]|25[0-5])";
// <dotnum> ::= <snum> "." <snum> "." <snum> "." <snum>
String dotnum_ = snum_ + "(?:\\." + snum_ + "){3}"; // + Dotted quad
// <element> ::= <name> | "#" <number> | "[" <dotnum> "]"
String element_ = "(?:" + name_ + "|#" + number_ + "|\\[" + dotnum_ + "\\])";
// <domain> ::= <element> | <element> "." <domain>
String domain_ = element_ + "(?:\\." + element_ + ")*";
// <mailbox> ::= <local-part> "@" <domain>
String mailbox_ = local_part_ + "@" + domain_;
emailMatcher = Pattern.compile(mailbox_);
System.out.println("Email address regex = " + emailMatcher);
}Wow. Sheesh, sabre150 that's pretty impressive. I like it for two reasons. First it avoids some false negatives that I would have gotten using the regex I mentioned. Like, [email protected] is a valid email address which my regex pattern has rejected and yours accepts. It's unusual but it's valid. And second I like the way you have compartmentalized each rule so that changes, if any custom changes are desired, are easier to make. Like if I want to specifically aim for a particular domain for whatever reason. And you've commented it so that it is easier to read, for someone like myself who knows almost nothing about regex.
Thanks, Good stuff! -
Match Regular Expression Function
Hi guys, using this pattern I got this error:
-4600 Error occurred during regular expression match.
I have attached the VI.
can you help me?thank you
Solved!
Go to Solution.
Attachments:
Untitled 2.vi 30 KBinuyasha84 wrote:
hi well i want to save (create) a file and do a check to see if the new file that I want to create already exist or not. so the idea was to see if the path of the new file is equal to the old path
Why not just use "Check if file or folder exists"? (File I/O -> Adv File Funcs)
Cameron
To err is human, but to really foul it up requires a computer.
The optimist believes we are in the best of all possible worlds - the pessimist fears this is true.
Profanity is the one language all programmers know best.
An expert is someone who has made all the possible mistakes.
To learn something about LabVIEW at no extra cost, work the online LabVIEW tutorial(s):
LabVIEW Unit 1 - Getting Started
Learn to Use LabVIEW with MyDAQ -
I just have questions about the AirPort Express and how it works.
My household Wi-Fi is not the strongest in my room and I found out about the AirPort Express and I read the overvie, but I still have some questions on how it works, how its setup and other questions as well.
The AirPort Express will not wirelessly extend the signal from another router unless that router is also an Apple product.
Not sure what other questions you might have, but we'll try to answer if you want to ask.
Maybe you are looking for
-
Cannot delete from Music Videos
cannot delete items from the [Music Videos] play list. The file do not exist anymore on the disk (I get the ! icon) still cannot delete the item. Redefining the [Music Videos] does not help, the files does note show up in the movies folder to delete
-
Hi, I have a requirement to fetch the view data from client instance(which is different server) to another instance lets say Development instance Requirement: Need to get the Apps View data from the Desired EBS instance(which is accessible online) us
-
Link cost a lot of time and memory, anybody know why
Does anybody have meat this problem. doring the linking time, it take a lot of memory and time. any one know how to solve this problem.
-
Get OSX to retrieve users from a specific AD OU.
Hi All, I work in a school with OSX and AD, two campuses (Secondary and Junior). On the Secondary campus we run the 'Golden Triangle' pretty well, but we just present a login box for users. On our Junior campus we run OSX as it's own directory master
-
When ever i plug in my ipod itunes freezes & when i unplug it goes back to normal & i got some new songs and i cant sync them on to my ipod