Regular Expressions Character Class shortcuts

I have been learning to use regular expressions to modify some of my text files. I noticed that on my ARCH box the Character Class shortcuts do not work e.g. [[:digit:]] in an expression works but \d does not. Is this normal or is my installation broken in some way?

Bebo wrote:
There are several regexp "dialects". It's quite painful actually For instance, as far as I know, \d works in perl, but not in sed or grep.
So, yes, this is normal.
Yeah -- Henry Spencer's regexp stuff is always generally considered the portable form for sed, awk, since they're all based from it.  Newer versions of grep though do allow for a -P flag for perl-regexps to be used, but this is non-portable, obviously.
-- Thomas Adam

Similar Messages

  • Regular Expression Character Sets with Pattern and Matcher

    Hi,
    I am a little bit confused about a regular expressions I am writing, it works in other languages but not in Java.
    The regular expressions is to match LaTeX commands from a file, and is as follows:
    \\begin{command}([.|\n\r\s]*)\\end{command}
    This does not work in Java but does in PHP, C, etc...
    The part that is strange is the . character. If placed as .* it works but if placed as [.]* it doesnt. Does this mean that . cannot be placed in a character range in Java?
    Any help very much appreciated.
    Kind Regards
    Paul Bain

    In PHP it seems that the "." still works as a all character operator inside character classes.
    The regular expression posted did not work, but it does if I do:
    \\begin{command}((.|[\n\r\s])*)?\\end{command}
    Basically what I'm trying to match is a block of LaTeX, so the \\begin{command} and \\end{command} in LaTeX, not regex, although the \\ is a single one in LaTeX. I basically want to match any block which starts with one of those and ends in the end command. so really the regular expression that counts is the bit in the middle, ((.|[\n\r\s])*)?
    Am I right it saying that the "?" will prevent the engine matching the first and last \\bein and \\end in the following example:
    \\begin{command}
    some stuff
    \\end{command}
    \\begin{command}
    some stuff
    \\end{command}

  • White space in regular expressions (Pattern class)

    Hello,
    I have to check if a String contains ONLY the following characters: a-z, A-Z, ' and ( ) .
    The regular expression that I wanted to use with the Pattern class was [[a-zA-Z][\u0027][\u0028][\u0029][\s]] .
    Now, my compiler (Eclipse) doesnt recognize \s as an expression. Is this the proper expression for a white space?
    Also, in this notation, will the Pattern check for the order of the characters, cause the order isn't supposed to matter.
    I would appreciate any help you could give me on this subject.
    With Best Regards, Roderick

    I'm not a regex expert, but I don't see any of the regex gurus online, and this I can tell you.
    my compiler (Eclipse) doesnt recognize \s as an expressionYou need to escape the backspace in a String literal. Use"\\s"
    in this notation, will the Pattern check for the order of the charactersFor that I think (note:think, not know) you need to put the entire set of characters to be matched in one character class. Could you try this and post back whether it works for your requirement?"[^a-zA-Z'()\\s]"Note the negation operator at the start of the characer class, which will match positive for any character not in the character class.
    db
    edit You can test your regex here:
    {color:0000ff}http://www.dotnetcoders.com/web/Learning/Regex/RegexTester.aspx{color}
    but remember to double the backslashes whe you include it in your java code as a String literal.
    Edited by: Darryl.Burke

  • Regular Expression Character Occurance.

    Hello,
    I have a name textfield and I want certain characters like "-" to occur one time only.
    i.e. The textfield can accept "Jean Luc" or "Jean-Luc" (french name), but not "Jean--Luc" or "Jean------------Luc" right.
    The regular expression  /\-?/ looks correct but it does not seem to work.
    We use "\" because "-" is an escape character and the character "?" to make "-" occur 0  or 1 time only.

    I am making sure that the textfield accept only text like "Jean-Luc" and not "-----Jean--Luc".
    My regular expression is already very long so I will add 5 or more additional parameters in the if statement which will not be a problem.
    Below is a very common regular expression which looks simple but it will not accept "[email protected]" and non western characters.
    /^[a-zA-Z0-9._-]+@[a-zA-z0-9.-]+\.[a-zA-z]{2,4}$/
    Email regular expressions are complicated. The range of permissible email adresses and some domain sometimes include non western characters which is quite rare but certainly does exist. I guess there is no precise regular expression for user forms.
    Checking user input becomes more complicated if some bored to death folks have a habit of playing drums on keyboard which result to "asdf;lkjasdf;lkjasdf;lkajsdf;lkajsdf;lkajsdf;lkj".

  • Unable to parse control character using regular expression & Pattern class

    I am trying to parse the Ctrl-X character from a string using the Pattern class but for some or the other reason it is not finding it.
    Here is the code that I wrote,
    Pattern p=Pattern.compile("\\cX");
    Matcher m=p.matcher(str);
    System.out.println(str+": "+m.find());
    the result is prop^Xau,bu,ca,en,fe,fi,ge,hj,ma,pe,re,sh,sr,tr^Yto^Xym^Yfmt^Xh : false
    where, str= prop^Xau,bu,ca,en,fe,fi,ge,hj,ma,pe,re,sh,sr,tr^Yto^Xym^Yfmt^Xh
    Thanks,
    Arunraj

    arunraj.nair wrote:
    I am trying to parse the Ctrl-X character from a string using the Pattern class but for some or the other reason it is not finding it.
    Here is the code that I wrote,
    Pattern p=Pattern.compile("\\cX");
    Matcher m=p.matcher(str);
    System.out.println(str+": "+m.find());
    the result is prop^Xau,bu,ca,en,fe,fi,ge,hj,ma,pe,re,sh,sr,tr^Yto^Xym^Yfmt^Xh : false
    where, str= prop^Xau,bu,ca,en,fe,fi,ge,hj,ma,pe,re,sh,sr,tr^Yto^Xym^Yfmt^XhWhat does str.length() give you? And posting, and trying with, a (much) shorter String might help you and others here to more easily see the problem.
    db

  • Regular Expressions with Java Regex

    Hi,
    I'm playing around with regex and there's something I can't get to work. What I need, is to capture words between 2 other words and the words captured has to be higher than 5 characters, so for example:
    Pattern "Just testing on something with regular expressions" and suppose I'll try to match all the words between "testing" and "regular", then only the word "something" should come out because "on" and "with" are not larger than 5 chars.
    Now I'm quite new to regexps and I know that ((?<=\btesting\b).*(?=\bregular\b)) will return " on something with "
    But I can't seem to come up with an expression that would only output the word "something". I've tried a few expressions like ((?<=\btesting\b)((?:[\s\w{1,3}])*(\b\w{4,}\b)*(?:[\s\w{1,3}])*)*(?=\bregular\b)) which also returns " on something with " The others I tried would either return the whole " on something with " or return "Not Found!"
    Does anyone have a tip for me? I'm well aware that it's not too hard to do something like this in Java, but I'm really looking to study regular expressions and would like to accomplish this using a regular expression.
    The Java program I use is the following:
    C:\Program Files\Java\jdk1.5.0_16\bin>java RegexTest "((?<=\btesting\b).*(?=\bregular\b))" "Just testing on something with regular expressions"
    public class RegexTest {
         public static void main(String[] args) {
              Pattern RegexCompile = Pattern.compile(args[0]);
              Matcher m = RegexCompile.matcher(args[1]);
              boolean found = m.find(); // Perhaps there's another function to find () that would do the job?
              if (found)
              System.out.println(m.group()); // Perhaps group() is not the right function for this case?
              else
              System.out.println("Not Found!");
    Edited by: dli2k3 on Sep 19, 2008 11:32 AM
    Edited by: dli2k3 on Sep 19, 2008 11:33 AM

    You're talking about a two-stage operation: find everything between those two words, then filter out anything that's less than five letters long. There's no single regex that will accomplish all that in one step.
    By the way, please use &#x7B;code} tags when you post source code.

  • Regular Expression back-reference in character class

    I am trying to capture quoted text (excluding the quotes) with the following pattern:
    "(['\"])([^\\1]+)\\1"
    The input string might look like:
    "That's strange"
    or:
    'valid "regex" pattern'
    I get an exception when trying to compile the pattern, because of the back-reference within character-class brackets: [^\1]
    This pattern worked with the org.apache.oro package. Is this a bug in the 1.4 Pattern class? Can you offer an alternative solution?
    Thanks,
    Tony

    Thanks for the reply. Apparently, my pattern wasn't working as I thought with ORO. The pattern you suggested, however, wouldn't do what I need either, because it would match anything between the first and last quote character. I don't want to match the string you included in your reply, because it includes the same quote character that encloses the entire string. If you think about my pattern again, you'll notice that the first capture group should match either a single or double quote character. Then the back-reference should be the exact character (single character) that was matched and captured. So the second capture group should be any number of characters, as long as they don't match the first capture group character, followed by the exact string matched in the first capture group (the single character). You probably are aware that when one or more characters are included in square brackets [], that it specifies a match of a single character that is found anywhere within that character class. So if the first capture group happened to match more than one character (impossible due to the pattern in that grouping), the following character class [^\1] should match any character EXCEPT any of the ones matched in the first capture group...right? There must be a bug in ORO that doesn't match correctly per my description, but it seems there is a bug in JDK 1.4 Pattern that will not even compile it. Just to re-iterate...if \1 matched "abc", [^\1] should match any single character EXCEPT a or b or c. I can get what I want, though, if I do it in 2 matches:
    Pattern pat = Pattern.compile("(['\"])(.*)");
    Matcher mat = pat.matcher(sText);
    mat.matches();
    String sQuote = mat.group(1);
    String sRem = mat.group(2);
    pat = Pattern.compile("([^" + sQuote + "]*)" + sQuote);
    mat = pat.matcher(sRem);
    mat.matches();
    String sWhatIWanted = mat.group(1);
    Thanks,
    Tony

  • Is there a way to be sure that created Regular expression (Class RegExp) is valid?

    Is it possible to create wrong Regular expression in  ActionScript/Flex which will cause runtime error? Or how to validate RegExp?
    I've tried so many  weird regexpes in Flash and Flex, it never complained! How do I know If my  regexp valid?

    "It is VERY reliable. If match() returns null - this means that String doesn't have any parts that match pattern."
    Exactly, but is doenst mean that syntax of RegExp is correct since you dont know what gave you null
    Apparemtly /foo([/ is wrong expression, and Java compiller complains:
    Unclosed character class near index 4 foo([     ^
    but in AS3 i can create
    var xxd:RegExp = /foo([/;
    when I do xxd.exec("") it got null;
    and no complains!! How to understand that?
    But in same time
    var xxd:RegExp = /foo/;
    xxd.exec(""), will be null as well!?

  • Regular Expression to Locate Words with Character

    I want to identify all the words in a document that are followed by the register mark (®) symbol.
    I built, what I thought was a regular expression that would search for a register mark preceeded by alpha number characters and a space. So if my text contained the sentence "Adobe InDesign® is a great product.", the regular expression would find "InDesign®"
    Below is the regular expression I composed. It grabs anything with a register mark, not just the register marks preceded by a space and alpha numeric characters. Where did I go wrong? I though the \s would restrict the search to complete words with a register mark.
    \s[a-zA-Z0-9]|®

    \s is the special GREP code for "any kind of space" -- a regular space, a tab, hard return, or any of ID's own white space codes. It has nothing to do with "complete words", because a word can appear at the start of a story, without any preceding space. It would also not find "InDesign®" because there is no space before it, there is a double quote instead.
    Your GREP does not work because, well, you got the general idea (words may consist of the set of characters "a-z", "A-Z", and "0-9") but since you use the [..] without any other code, GREP will apply this rule once -- per character. If you want to find words of more than one character, you need to tell GREP "one or more of these, please": with a +.
    Second, where did that | come from? It's the OR operator. Essentially, you are looking for
          any space followed by one character from the set "a-z", "A-Z", and "0-9"
    OR
          the ® character
    The 'word break' you were looking for is this code: \b, so you could search for "\b[a-zA-Z0-9]+" (note the '+' to allow more than one instance) -- but it's not necessary, because by default GREP grabs as much as it can. The set 'a-zA-Z0-9' etc. describes the allowed "word" characters, but you might want to prefer these: \l (ell) and \u for all lowercase and all uppercase characters -- they are shorter, and they automatically include accented characters, Greek, Russian, and a lot more. Similar, \d (for "digits") is the short-cut for "0-9". And even better: \w is the shortcut for "word character", i.e., your set but then shorter and a bit better.
    Try this one:
    \w+~r

  • Regular Expression Escaped Digit "\d" Illegal Escape Character

    Hello,
    I'm trying to write a regular expression to determine if a String matches a date format that is defined as YYYYMMDD. For example, March 11, 2009 would be "20090311"
    For the time being I don't care if an invalid month or day is entered. I've attempted both of the following
    if (date.matches("(19|20)\d{4}")) {
      // warn the user
    }and
    if (java.util.regex.Pattern.matches("(19|20)\d{4}"), date)) {
      // warn the user
    }And both yield Illegal Escape Character compilation errors, for the "\d" part of the regular expression.
    http://java.sun.com/j2se/1.4.2/docs/api/java/util/regex/Pattern.html#sum
    Says that "\d" is the predefined digit character class. So at this point, I don't know what I'm doing wrong. I realize I could just define the character class myself, and use a pattern like "(19|20)[0-9]{4}", but I would like to know why "\d" isn't being recognized by the compiler.
    Thanks,
    Paul

    paulwooten wrote:
    Can someone give me an explanation of heuristics, as they might apply to SimpleDateFormat? Does this mean that if the format was similar the parser might figure it out? Say, if instead of "yyyyMMdd", it was "yyyyddMM", or "yyMMdd"?No. Since all of these are valid formats, there's no way for the parser to distinguish this.
    Or does this have to do with rejecting February 29, and other dates like that.That's the one. When setLenient(false) is called, then the 29th February is only accepted in leap years.
    It will also reject the 57th January when lenient is set to false (try parsing that with lenient=true, you'll be surprised).
    I've read some of the wikipedia article about heuristics, but I'm confused as to how it would apply to this example.Don't concentrate to much on the term heuristics. Just remember: lenient=true means that not-really-correct dates will be accepted, lenient=false means more strict checks.

  • Re: [iPlanet-JATO] Re: Use Of models in utility classes - Pease don't forget about the regular expression potential

    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]

  • How to specify ");" as a regular expression in split method of String class

    How to specify ");" as a regular expression in split method of String class using delimeters?

    Sorry, you can't specify that by using delimiters. Mostly because this requirement makes no sense.
    Do you rather need "\\);"?

  • Regular expressions with multi character separator

    I have data like the
    where |`| is the separator for distinguishing two fields of data. I am having trouble writing a regular expression to display the data correctly.
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    SQL> declare
      2  l_string varchar2 (200) :='123` 456 |`|789 10 here|`||223|`|5434|`}22|`|yes';
      3  v varchar2(40);
      4  begin
      5  v:=regexp_substr(l_string, '[^(|`|)]+', 1, 1);
      6  dbms_output.put_line(v);
      7  v:=regexp_substr(l_string, '[^(|`|)]+', 1, 2);
      8  dbms_output.put_line(v);
      9  v:=regexp_substr(l_string, '[^(|`|)]+', 1, 3);
    10  dbms_output.put_line(v);
    11  v:=regexp_substr(l_string, '[^(|`|)]+', 1, 4);
    12  dbms_output.put_line(v);
    13  v:=regexp_substr(l_string, '[^(|`|)]+', 1, 5);
    14  dbms_output.put_line(v);
    15  end;
    16  /
    123
    456
    789 10 here
    223
    5434I need it to display
    123` 456
    789 10 here
    |223
    5434|`}22
    yesI am not sure how to handle multi character separators in data using reg expressions
    Edited by: Clearance 6`- 8`` on Apr 1, 2011 3:35 PM
    Edited by: Clearance 6`- 8`` on Apr 1, 2011 3:37 PM

    Hi,
    Actually, using non-greedy matching, you can do what you want with regular expressions:
    VARIABLE     l_string     VARCHAR2 (100)
    EXEC  :l_string := '123` 456 |`|789 10 here|`||223|`|5434|`}22|`|yes'
    SELECT     LEVEL
    ,     REPLACE ( REGEXP_SUBSTR ( '|`|' || REPLACE ( :l_string
                                     , '|`|'
                                      , '|`||`|'
                                     ) || '|`|'
                        , '\|`\|.*?\|`\|'
                        , 1
                        , LEVEL
               , '|`|'
               )     AS ITEM
    FROM     dual
    CONNECT BY     LEVEL     <= 7
    ;Output:
    LEVEL ITEM
        1 123` 456
        2 789 10 here
        3 |223
        4 5434|`}22
        5 yes
        6
        7Here's how it works:
    The pattern
    ~.*?~is non-greedy ; it matches the smallest possible string that begins and ends with a '~'. So
    REGEXP_SUBSTR ('~SHALL~I~COMPARE~THEE~', '~.*?~', 1, 1) returns '~SHALL~'. However,
    REGEXP_SUBSTR ('~SHALL~I~COMPARE~THEE~', '~.*?~', 1, 2) returns '~COMPARE~'. Why not '~I~'? Because the '~' between 'SHALL' and 'I' was part of the 1st pattern, so it can't be part of the 2nd pattern. So the first thing we have to do is double the delimiters; that's what the inner REPLACE does. The we add delimiters to the beginning and end of the list. Once we've done prepared the string like that, we can use the non-greedy REGEXP_SUBSTR to bring back the delimited items, with a delimiter at either end. We don't want those delimiters, so the outer REPLACE removes them.
    I'm not sure this is any better than Sri's solution.

  • Regular Expression Class in RoboHelp

    Is there any class in RoboHelp object model for working with regular expressions? Or maybe a class for find and change option?
    In Javascript there is RegExp class. Does RoboHelp have the same?

    I suspect you have a development background which I do not have. Regular expressions work just fine from the tools I have used (as above plus dnGrep) but I think you want to create a script of some sort that takes in regular expressions, effectively replacing the tools I have used to run the expressions. I am sorry I cannot help you on that Charlotte.
    Curiosity makes me ask why you have to do this with your own script rather than the tools I have used.
    See www.grainge.org for RoboHelp and Authoring tips
    @petergrainge

  • Writing Regular Expression with a character ^, too difficult

    I want to change "^1Mandrake ^3Style ^4DM" this sentence to "Mandrake Style DM".
    (^ with number means color code)
    So..I used String.replaceAll() method with regular expression.
    But however hard I try, I cant find any solution for this.
    In php I could use \^ as a ^ character, but java dosnt support \^.
    How can I solve this problem?

    Use \\^ in your regex (you have to escape the slash, too).

Maybe you are looking for

  • Error while Loading the WSDL

    Hi, Getting error while loading the WSDL in Browser.Mentioned below is the link which trying to load. http://10.162.32.113/DNBDAASEXCMDL4/AdapterProductService?wsdl The XML page cannot be displayed Cannot view XML input using XSL style sheet. Please

  • Working with excel files in C#, in a web farm

    I am creating a excel file uploader that after the upload, searches for specific columns, saves data to SQL Server, then gets rid of the excel file. I will be accepting .xls & xlsx file types.  The internal file structure should be all fairly standar

  • Final Cut 5.0 wont open after hard drive confusion

    i think someone in my studio unplug a external hard drive because when i checked the timeline many files were offline i closed out of the program and re-opened and it said all my mac hd hard drive was offline i tried to reconnect it and once i did it

  • Perhaps my images are hopelessly mixed up.  Help!

    I have paid little attention to where I've put roughly 5000 separate images in my desktop and laptop computers (running Vista and XP, respectively). Often I could not figure out how to get images into LR and reimported them from disk even though they

  • How to share one custom field from FITE_VC_GENERAL_DATA to FITE_VC_REVIEW

    Hi FORUM   I haved created one custom field in the FITE_VC_GENERAL_DATA by one Enhancement, to get this custom field in FITE_VC_REVIEW screen, i filled a z_table_tmp, but i´m not happy with this solution and i thinked that is not the best way. How ca