Got more questions? Find advice on: ASP | SQL | XML | Windows
in Search
Welcome to RegexAdvice Sign in | Join | Help

Regular Expression for xml MatchPattern node (Help)

Last post 06-19-2010, 6:48 PM by RegexNewbie. 0 replies.
Sort Posts: Previous Next
  •  06-19-2010, 6:48 PM 68279

    Regular Expression for xml MatchPattern node (Help)

    Helo everyone,

     

    I am new here and today I had my first expression with Regular Expressions. I read for hours and I am trying but my expression doesnt work. I Have a xml that has the rules for extracting some values from a file to show them to thes users (the program is in VB). The file contains this line -->

    Delivery: Phone:989909 Country:Blabla Type1        A  1232 Town:BLKAKAKAKK

     Delivery: Phone:898989 Country:Blabla Type2334 B 2223 Town:ujhsuhwuhu jjjhj

     Delivery: Phone:122344 Country:Blabla Type3  C 2222 Town:uhuhuh

     I need the values (not numeric) A,B,C (len = 3) after the Strings Type1,Type2334,Type3 and before the Town String. The four Strings are Const. So I have created the following Regex for the xml-->

    <MatchPattern><![CDATA[(?<=Type1|Type2334|Type3\s+).{1,17}\s*.{1,17}\s*)]]></MatchPattern>

    ?<=Type1|Type2334|Type3\s+).{1,17}\s*.{1,17}\s* 

     It works fine but sometimes I  get the wrong result. Thats because the length of the String is  not allways the same and the spaces are too many... I have no Idea what I can do to solve this problem. I have tried to combine the negative lookahead but it doesnt work -->

    <MatchPattern><![CDATA[(?<=Type1|Type2334|Type3\s+).{1,17}\s*.{1,17}\s*(?<!Town\s+)]]></MatchPattern>  (I dont remember right now the syntax for a negativ lookahead).

    The result was nothing. I need really Help. Please tell me also if there is a way to ignore spaces. Thank you very Much!  The XML Code follows -->

     

     <DocFields><ID>DocSeries</ID>

        <fDocTypeID>A</fDocTypeID>

        <FromTop>true</FromTop>

        <StartRow>15</StartRow>

        <StartColumn>1</StartColumn>

        <Width>158</Width>

        <Height>1</Height>

        <MatchPattern><![CDATA[(?<=Type1|Type2334|Type3\s+).{1,17}\s*.{1,17}\s*)]]></MatchPattern>

        <Optional>false</Optional>

      </DocFields>

     

View as RSS news feed in XML