Help needed on Regular expressions

Hi All,
I need to extract the value of the below 2 tags
1. <S143:name> (main tag not the <S143:name> of <S143:specCharacteristicProperty>)
2. <S110:stringValue>
<S211:falloutCharacteristic>
               *<S143:name>String</S143:name>*               <S143:value>
                    <S110:stringCharacteristicEnum>
                         *<S110:stringValue>String</S110:stringValue>*                         <S110:stringRestriction>
                              <S110:minLength>0</S110:minLength>
                              <S110:maxLength>0</S110:maxLength>
                              <S110:pattern>String</S110:pattern>
                         </S110:stringRestriction>
                    </S110:stringCharacteristicEnum>
               </S143:value>
               <S143:description>String</S143:description>
               <S143:specCharacteristicProperty>
                    <S143:name>String</S143:name>
                    <S143:value>String</S143:value>
               </S143:specCharacteristicProperty>
          </S211:falloutCharacteristic>Any pointers on this?
Thanks in advance.

Well..Personally i feel regex on this would be a tough job. You try creating a temp file and pass your xml string along. Then try using org.w3c.dom on it. Something like :
String xmlString = "Your XML String";
          File temp = null;
          try {
               temp = File.createTempFile("test",".xml");
               temp.deleteOnExit();
               BufferedWriter out = new BufferedWriter(new FileWriter(temp));
               out.write(xmlString);
               out.close();
          } catch (IOException e) {
               e.printStackTrace();
          }Or you could actually create a physical file, if space and credentials permit, access it from a physical location and try using DOM in it.. Cant think of anything better now.

Similar Messages

  • Help needed regarding regular expressions

    hello
    i need to write a program that recieves a matematical expression and evaluates
    it...in other words a calculator :)
    i know i need to use regular expressions inorder to determine if the input is legal or not ,but i'm really having trouble setting the pattern
    the expression can be in the form : Axxze2223+log(5)+(2*3)*(5+4)
    where Axxze2223 is a variable(i.e a combination of letters and numbers.)
    where as: l o g (5) or log() or Axxx33aaaa or () are illegal
    i tried to set the pattern but i got exceptions or it just didnt work the way i wanted it .
    here's what i tried to do at least for the varibale form:
    "\\s*(*([a-zA-Z]+\\d)+)*\\s*";
    i'm really new to this...and i can't seem to set the pattern by using regular expressions,how can i combine all the rules to one string?
    any help or references would be appreciated
    thanks

    so i'll explain
    let's say i got token "abc22c"(let's call it "token")
    i wan't to check if it's legal
    i define:
    String varPattern = "\\s*[a-zA-Z]+\\d+\\s*";If you want to check a sequence of ASCII characters, longer than one, followed by a single digit, the whole possibly surrounded by spaces -- yes.
    >
    now i want to check if it's o.k
    so i check:
    token.matches(varPattern);
    am i correct?Quite. It's better to compile the Pattern (Pattern.compile(String)), create a java.util.regex.Matcher (Pattern#matcher(CharSequence)), and test the Matcher for Matcher#matches().
    (Class.method -> static method, Class#method -> instance method)
    >
    now i'm having problem defining pattern for log()
    sin() cos()
    that brackets are mandatory ,and there must be an
    expression inside
    how do i do that?First, I'd check the overall function syntax (a valid name, brackets), then whether what's inside the brackets is a valid expression (maybe empty), then whether that expression is valid for that function (presumably always?).
    I might add I'm no expert on parsing, so that's more a supposition than a guide.

  • Help needed in Regular Expression

    I have been give a task to replace all table_name (Emp) in Procedure p1 to Table_name(Employee).
    Can anyone help me ?
    Regards,
    Prathamesh

    Hi, Prathamesh,
    REGEXP_REPLACE ( txt
                , '(^|\W)emp(\W|$)'
                , \1employee\2'
                )will return a copy of txt with the full word 'emp' replaced by 'employee'.
    For example, if txt is:
    emp foo a=emp  temp emp_name emp.bthe expression above will return
    employee foo a=employee  temp emp_name employee.b 
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statments) and the results you want from that data.

  • Need a regular expression for the text field

    Hi ,
    I need a regular expression for a text filed.
    if the value is alphanumeric then min 3 char shud be there
    and if the value is numeric then no limit of chars in that field.[0-9].
    Any help is appriciated...
    thanks
    bharathi.

    Try the following in the change event:
    r=/^[a-z]{1,3}$|^\d+$/i;
    if (!r.test(xfa.event.newText))
    xfa.event.change="";
    Kyle

  • Need help in unix regular expressions

    Hi All,
    I'm new to shell scripting. Please help me in achieving this
    I am trying to a find regular expression that need to pick a file with begin with the below format and mask variable is called in xml file.
    currently the script accepts:
    mask="CLIENT_ID+'_ADHSUITE_IN_'+date2str(now,'MMddyy','US/Eastern')+'.txt'"
    But it should accept in the below format
    2595_ADHSUITE_IN_ANNWEL_030309_2009-02-10_15-12-46-000_648.TXT715.outpgp_out
    where CLIENT_ID=2595. How to place wild card character '*' in the below to accept file in the above format. here is what i made changes.
    mask="CLIENT_ID+'_ADHSUITE_IN_'*+date2str(now,'MMddyy','US/Eastern')*+'.TXT'*+'.outpgp_out'"
    Please help.
    Thanks

    I believe your statement is being passed over twice:
    First Pass: (This is done by something like javascript)
    CLIENT_ID+'_ADHSUITE_IN_'+'.*'+date2str(now,'MMddyy','US/Eastern')+'.*'+'.TXT'+'.*'+'.outpgp_out'In this pass the variables and functions that are enclosed in literals are processed:
    (1) CLIENT_ID is replaced by 2595 or whatever is current value is:
    (2) date2str(now,'MMddyy','US/Eastern') gets replaced by 040609 (if the current time now is 4th april 2009).
    So at the end of this first pass we have a string:
    2595_ADHSUITE_IN_.\*040609.\*.TXT.*.outpgp_outThis string at the end of the first pass is a Posix basic regular expression. (ref: [http://en.wikipedia.org/wiki/Regular_expression] ) accessed at time of post).
    This is the string I put in the Regular Expression text box on [http://www.fileformat.info/tool/regex.htm]
    and it matches "2595_ADHSUITE_IN_ANNWEL_040609_2009-01-27_17-02-28-000_631.TXT715.outpgp_out" for me (though I prefer my egrep test).
    I hope this is somewhat clearer. Remember I have very little information about your system/application and I make big guesses.
    NB: (I should thank Frits earlier for pointing my sloppiness between wildcards (for eg unix shell filename expansion) and regular expressions).
    For the second pass this used to compared other strings to see

  • Need help in writing regular expressions involving \w

    Hi,
    Here is my requirement .
    I have a string : GTA - 12AB TRA - 12AB
    I need a regex that represent above string.
    GTA - Constant - This wont change
    12AB - This will be \w (alphanumeric)
    Here I cannot have TRA within this 4 characters.
    The question is :
    How can I write an expression which says it can be a word(the positions where I have 12AB in example) but not TRA in sequence.
    Is this doable?
    Thanks in advance.

    Use lookarounds: [http://www.regular-expressions.info/lookaround.html]
    The regex:
    (?!.?TRA).{4}matches any 4 characters (except line breaks) that does not contain 'TRA'.

  • Help with Understanding Regular Expressions

    Hello Folks,
    I need some help in understanding the Regular Expressions.
    -- This returns the Expected string from the Source String. ", Redwood Shores,"
    SELECT
      REGEXP_SUBSTR('500 Oracle Parkway, Redwood Shores, CA,aa',
                    ',[^,]+,', 1, 1) "REGEXPR_SUBSTR"
      FROM DUAL;
    REGEXPR_SUBSTR
    , Redwood Shores,
    However, when the query is changed to find the Second Occurrence of the Pattern, it does not match any. IMV, it should return ", CA,"
    SELECT
      REGEXP_SUBSTR('500 Oracle Parkway, Redwood Shores, CA,aa',
                    ',[^,]+,', 1, *2*) "REGEXPR_SUBSTR"
      FROM DUAL;
    REGEXPR_SUBSTR
    NULLCan somebody help me in understanding Why Second Query not returning ", CA,"?
    I did search this forum and found link to thread "https://forums.oracle.com/forums/thread.jspa?threadID=2400143" for basic tutorials.
    Regards,
    P.

    PurveshK wrote:
    Can somebody help me in understanding Why Second Query not returning ", CA,"?With your query...
    SELECT
      REGEXP_SUBSTR('500 Oracle Parkway, Redwood Shores, CA,aa',
                    ',[^,]+,', 1, *2*) "REGEXPR_SUBSTR"
      FROM DUAL;You are looking for patterns of "comma followed by 1 or more non-comma chrs followed by a comma."
    So, let's manually pattern match that...
    '500 Oracle Parkway, Redwood Shores, CA,aa'
                       ^               ^
                       |               |
                               |
                               |
                      Here to here is the
                      first occurence.So the second occurance will start searching for the same pattern AFTER the first occurence.
    '500 Oracle Parkway, Redwood Shores, CA,aa'
                                        ^
                                        |
    i.e. the search for the second occurence starts heretherefore the first "," from that point is...
    '500 Oracle Parkway, Redwood Shores, CA,aa'
                                           ^
                                           |
                                          hereand there is nothing there matching the pattern you are looking for because it only has the
    "comma follwed by 1 or more non-comma chrs"... but it doesn't have the "followed by a comma"
    ...so there is no second occurence,

  • Urgent help regarding Java regular expressions.

    hello everyone,
    I am trying to parse a html file which contains
    dyn.Img("http://www.boston.com/news/nation/articles/2007/06/21/bill_clinton_takes_bigger_campaign_role&h=306&w=410&sz=13&hl=en&start=43","","QFo9lqKeMR7uzM:","http://cache.boston.com/resize/bonzai-fba/AP_Photo/2007/06/21/1182410228_1931/410w.jpg","125","93","\x3cb\x3eBill Clinton\x3c/b\x3e takes bigger campaign \x3cb\x3e...\x3c/b\x3e","","","410 x 306 - 13k","jpg","www.boston.com","","","http://tbn0.google.com/images","1")
    the given above function many times. I have to fetch the whole functions into an array. So i have to write a regular expression which recognises the whole above string.
    Can anyone please help me.
    Thank you,
    chaitanya

    well if this is all you want
    http://cache.boston.com/resize/bonzai-fba/AP_Photo/2007/06/21/1182410228_1931/410w.jpg
    You can always substring it like chuck said
    ***BUT all the images would have to be .jpg for this to work***
    back = we.indexOf(".jpg");
    int x = 0;
    while (back < web.lastIndexOf(".jpg"))
                    back = web.indexOf("http",back+1);
                    picture[x] = web.substring(front, back);
                    x++;
                    front = back;
                  }       Might not be the best code but it worked with a website i had to parse
    Message was edited by:
    mark07

  • Need a regular expression for URL

    Regular expression: ^(udp|norm)://(?:(?:25[0-5]|2[0-4]\\d|[01]\\d\\d|\\d?\\d)(?(?=\\.?\\d)\\.)){4}:(6553[0-5]|655[0-2][0-9]\\d|65[0-4](\\d){2}|6[0-4](\\d){3}|[1-5](\\d){4}|[1-9](\\d){0,3})$
    Source: udp://125.3.4.121:23456
    Getting error:java.util.regex.PatternSyntaxException: Unknown inline modifier near index 54
    ^(udp|norm)://(?:(?:25[0-5]|2[0-4]\d|[01]\d\d|\d?\d)(?(?=\.?\d)\.)){4}:(6553[0-5]|655[0-2][0-9]\d|65[0-4](\d){2}|6[0-4](\d){3}|[1-5](\d){4}|[1-9](\d){0,3})$

    paulcw wrote:
    I can't help wondering if a simpler solution would involve creating a java.net.URL object, passing it the string to be checked, and let URL do the parsing and an initial pass at checking the syntax. Then you could query URL for individual components for further checking (e.g., getting the transfer type to make sure it's one of the kinds you want). This approach would probably be more self-documenting, if nothing else.Nice idea, but java.net.URL doesn't actually do much work at all. It basically takes the protocol part, looks up a handler for it, and delegates everything else to that. The handlers themselves are down in the sun packages (or whatever your Java impl is) and since there isn't one for the OPs protocol, he'd have to write and register his own anyway, which kind-of negates the entire purpose of leveraging it.
    @OP: Paul's suggestion can still be of use. Apache, Codehaus and the like will have written their own protocol handlers, it's worth grabbing the source code for, say, Apache HttpClient, and seeing if they've got anything useful in there. Then again, who's to say that what's a valid URL for this 'norm' protocol, other than whoever designed the protocol?

  • Open APEX Wiki needs a regular expression mastermind

    Hello,
    And I'm not talking about someone that kinda knows regular expression's, we need one of those sick in the head people that think regular expressions are fun to do on a Friday night :) for some of this wiki work.
    If your interested please email me directly at [email protected]
    Sorry for putting this out here but I'm throwing a wide net on this one and want to kickstart this application.
    Carl

    [Heh, the "not built here", "we can build it better" approach, the bane (and boon!) of all software development]
    Seriously, I don't think Perl regexps are all that "non-standard" as compared to the POSIX standard. They certainly have some quirks w.r.t zero-length forward/backward assertions (?pattern) and they might have some more character classes [[:pattern:]] but on the whole it is the same stuff.
    Yes, given that TWiki is built entirely in Perl, it might have more than its fair share of "Perl-isms" that might make converting to Oracle regexps untenable, but there is no reason to use the TWiki "dialect" of wiki-markup. There are tons of Wiki dialects around, Google for keywords like "wiki dialect markup convert html" finds lots of relevant hits (like the link I posted earlier).
    All I am saying is that it might make sense to not reinvent the wheel especially for something as complicated as regular expressions.
    References:
    http://www.ayni.com/perldoc/perl5.8.0/pod/perlre.html
    http://builder.com.com/5100-6388-5224420.html
    http://www.oreilly.com/catalog/oracleregex/index.html
    http://www.redwingnet.com/hioug/Presentations/Regular_Expressions/Oracle10gRegularExpressions.htm

  • Help with java regular expressions

    Hi all ,
    i am going to match a patternstring against an input string and print the result here is my code:
         import java.util.regex.*;
         import java.util.*;
         public class Main {
              private static final String CASE_INSENSITIVE = null;
              public static void main(String[] args)
              CharSequence inputStr = "i have 5 years FMCG saLEs exp on java/j2ee and i worked on java and j2ee and 2 projects on telecom java j2ee domain with your  with saLEs maNAger experience of java j2ee and c# having very good  on c++ exposure in JAVA"
             String patternStr = "\"java j2ee\" and \"c#\"";
              StringTokenizer st = new StringTokenizer(patternStr,"\",OR");
             Matcher matcher=null;
              while(st.hasMoreTokens()){
                   String s=st.nextToken();
                   Pattern pattern = Pattern.compile(s,Pattern.CASE_INSENSITIVE);
               matcher = pattern.matcher(inputStr);
               while (matcher.find()) {
                  String result = matcher.group();
                 if(!result.equalsIgnoreCase(" "))
                             System.out.println("result:"+result);
         when i compile this code i am getting the expected result...ie
    result:java j2ee
    result:java j2ee
    result: and
    result: and
    result: and
    result: and
    result: and
    result: and
    result:c#
    but when i replace String patternStr = "\"java j2ee\" and \"c#\""; with
    String patternStr = "\"java j2ee\" and \"c++\""; i am just getting c in the result instead of c++ ie i am getting result :
    result:java j2ee
    result:java j2ee
    result: and
    result: and
    result: and
    result: and
    result: and
    result: and
    result:C
    result:c
    result:c
    result:c
    result:c
    result:c
    result:c
    In the last lines i should get result:c++ instead of result: c
    Any ideas please
    Thanks

    In the last lines i should get result:c++ instead of result: cThe regular expression parser considers the plus sign '+' a special
    character; it means: one or more times the previous regular expression.
    So 'c++' means one or more 'c's on or more times. Obviously you don't
    want that, you want a literal '+' plus sign. You can do that by prepending
    the '+' with a backslash '\'. Unfortunately, the javac compiler considers
    a backslash a special character and therefore you have to 'escape'
    the backslash also, by adding another backslash. The result looks
    like this:"c\\+\\+"kind regards,
    Jos

  • Little help with this regular expression ?

    Greetings all,
    My string is like "P: A104, P105, K106" and I tried to split it using following regular expression ,but seems even though it returns 'true' as matched, it does not split the string.
    Finally what I want is String is array like {"P:","A104","P105","K106"}
    What seems to be the problem with my regular expression?
           String PAT1="[a-zA-Z]:\\s([a-zA-Z]\\d{1,}([,]\\s)?)*";
         String inp="P: A104, P105, K106";
         Pattern p=Pattern.compile(PAT1);
         System.out.println(p.matcher(inp).matches());
         String strs[]=inp.split(PAT1);
         for(String s:strs){
              System.out.println("part  "+s);
         }

    pankajjaiswal10 wrote:
    You can also use split(":|,")No, that will remove the colon and leave the whitespace intact. My understanding is that the OP wants to keep the colon and remove the commas and whitespace. I would use this: String[] strs = inp.split(",?\\s+");

  • Need help starting with regular expressions

    Hi,
    looked through the tutorials, and some stuff online and still having trouble.
    I've done a fair amount of modifying xml files with perl, and want to do the same thing with java.
    I'm writing this at work, and we don't have the 1.5 jdk installed, so I can't use the Pattern and Match objects.
    Here's some code I wrote:
    package pack1;
    import java.io.BufferedReader;
    import java.io.FileNotFoundException;
    import java.io.FileReader;
    public class PlantTest {
          * @param args
          * @throws Exception
         public static void main(String[] args) throws Exception {
              // get file to read from
              java.io.File infile = new java.io.File("plant.xml");
              FileReader infileReader = new FileReader(infile);
              BufferedReader bInfile = new BufferedReader(infileReader);
              //get basic file info
              System.out.println("does the file exist? " + infile.exists());
              System.out.println("file is located at: " + infile.getAbsolutePath());
              System.out.println("file was last modified: " + new java.util.Date(infile.lastModified()));
              // create a pattern
              String match = "<COMMON>";
              String line = bInfile.readLine();
              while (line != null){
                   //System.out.println(bInfile.readLine());
                   if (line.matches(match)){
                        System.out.println("match made: " + line);
              bInfile.close();
              infileReader.close();
    }I want the "match" object to be the equivalent of this in perl:
    (I realize I don't have the output set up in the code above, I was going to add it later, for now I just want to make the match and print something on the console)
         m/<COMMON>([^<]+)</COMMON>/i;
         $common = $1;
         print HTML "<p>Common Name: $common\n";here's a snippet of xml:
         <PLANT>
              <COMMON>Bloodroot</COMMON>
              <BOTANICAL>Sanguinaria canadensis</BOTANICAL>
              <ZONE>4</ZONE>
              <LIGHT>Mostly Shady</LIGHT>
              <PRICE>$2.44</PRICE>
              <AVAILABILITY>031599</AVAILABILITY>
         </PLANT>(I cribbed that xml from the w3c site)
    thanks in advance,
    bp
    Message was edited by:
    badperson

    ouch. 1.3.1...
    That's here at work, I'm kind of nervous about
    downloading another jdk, will there be a conflict?Google for Jakarta ORO regex. It is about the same speed as Java regex and works well with JDK1.3.1 .

  • Help Needed with Airport Express

    Hi All,
    I have recently purchased a new Airport Express with AirTunes and installed the Airport Setup on my laptop as provided on the CD. I am using the Windows Wireless Zero Configuration service to connect to the wireless networks.
    I am able to connect to my internet connection (MTNL Broadband service) using the AEX, but to my surprise Airport Setup Assistant finds the AEX in the scan but is not able to connect to it. However in the background I can see the network connection is established.
    Also the Aiport Admin Utility is not able to even find the AEX in the scan. However if I type the IP address of the AEX on the 'Other' option then it makes a successful connection and show me the dialog box with the AEX properties.
    Would appreciate if anybody could help.
    Thanks,
    Gaurav
    IBM Thinkpad T43 Laptop Windows XP Pro SP2 installed

    Most/many cable modems require that they be reset whenever you switch the Ethernet connection from one device to another. This usually means that you need to power off the cable modem for a minute or two. When the cable modem powers up it will detect the new device and talk to it.
    Some cable modems have a reset button. Some cable modems have a small internal battery which must be removed to do the reset.
    Sometimes the cable modem must be turned off overnight to reset equipment back at the ISP.
    Have you don this? I didn't see mention of it in your post.

  • Help needed in JSP Expression Language

    Hi all,
    I have been working for JSP Expression Language Sample execution since past 5 days. I am using the application server as "Jboss Server" and web server as "Tomcat".
    I have been included the jsp-api.jar file in my lib directory of application server as well as source folder's lib directory.
    When i am trying to build the source code, i am getting this build error.
    [javac] D:\eclipse\workspace\esolvProject\development\src\com\esolv\taglibs\
    web\classes\SetSupport.java:186: cannot resolve symbol
    [javac] symbol : method getExpressionEvaluator ()
    [javac] location: class javax.servlet.jsp.PageContext
    [javac] ExpressionEvaluator evaluator = pageContext.getExpressionEvaluator();
    In my jsp-api.jar , there are two classes called,
    PageContext and JspContext, Both are abstract classes.
    PageContext inherits JspContext class. JspContext class have the method getExpressionEvaluator() , returns ExpressionEvaluator.
    PageContextImpl - class . it has been called internally when we are trying to call PageContext class. In PageContextImpl class, there is one comment before, the method's definition. that is
    " Since JSP 2.0 "
    But we have the JSP 2.0 version. But it won't work.
    Please help me ont this.
    Thanks in Advance,
    Natraj

    >
    If the pblm was due to setting the classpath.
    The error should be showed for all files in the jar
    file.
    why i am getting the error for particular method ?
    it is accessing the other methods of same class
    'JspContext' . but it is not accessing that method.
    Thats my question.
    Just check that your .jar file is 2.0 compliant and that you do not have any other jars(for servlet or jsp api) in the classpath.
    Probably you have an older version of .jar file in your path. So the errors will appear only for those methods that have been added since 2.0, all other methods would compile fine.
    Please tell me the jar files to work out the
    expression language. so that i can cross check my
    list of jars.Hmmm...I dont use jboss. In tomcat the jar file name is jsp-api.jar. But it would have been the same even for jsp1.1, going by jar file names wouldnt help. Just look at your cp as if with a microscope to identify redundant jars.
    cheers,
    ram.

Maybe you are looking for

  • Why a method can not be invoked in JSP ???

    I define a method in a JAVA Class file,as this: public Enumeration getElementsNamed(String name, String parentname) { Element elem = doc.getDocumentElement(); NodeList nodes = elem.getElementsByTagName(name); int size = nodes.getLength(); Vector elem

  • HT1338 os x mountain lion updates issues

    Hi, i am using macbook air 13 intch. i updated my software to os x moutain lion 10.8.1. but my computer faced many troubles. like face time, imessage, mails amd system preferemces cannot react. i have also guest user on my computer work proporly but

  • About converting a file into PDF

    why an error always occur when converting a file into pdf ?

  • Po workflow( release strategy)

    hi,   we had defined release strategy for po workflow. i assigned the users to release codes in SPRO. what my doubt is .... is there any further configuration is there to go purchase order to agent inbox. i am not defining workflow template. is it re

  • How can I turn off that everything I select gets copied to clipboard?

    It's really annoying when I have something copied and before I could paste it where I want it I accidentally select a letter or something and than that's on clipboard without me selecting 'copy' == I don't know but by now it seriously irritates me