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

Please help with this expression

Last post 05-09-2008, 3:18 AM by youquijano. 2 replies.
Sort Posts: Previous Next
  •  05-09-2008, 2:30 AM 42068

    Please help with this expression

    \s{5}J\s.*\w

     i used this expression to find all entries that has a prefix of 5 spaces and J in the sixth position of the entry

    my problem is how to find the C-1-03 in the sample below... it does'nt really mean the exact string but what

    i want  is to match an entry which has a non-space at the 30th column
     

         J           9AT     67  C-1-03C9  5                                  991001
     

  •  05-09-2008, 2:51 AM 42069 in reply to 42068

    Re: Please help with this expression

    Assuming that you also want the s spaces followed by a J as well, then

    ^\s{5}J\s.{22}\S

    will do it. If there are multiple lines in the text that you are scanning, then you will also need to use 'multiline' mode so that the '^' will apply to the start of each line, not just the start of the text.

    If you just want to find a non-blank in column 30, then

    ^.{29}\S

    will work. If you want to match the characters in columns 30 to 35 then

    ^.{29}(\S(6})

    Because you question is quite loosely worded, I may not have captured your requirements. If not, then try playing with the various components of the samples above, and if that is not enough, then get back with the exact requirements and some real sample text for us to test.

    Also, please read the posting guidelines in the sticky note at the start of this forum for guidance on how to ask your question. I've tried to use generic regex commands so that this should work whatever your regex and language, but there are no guarantees.

    Susan 

  •  05-09-2008, 3:18 AM 42070 in reply to 42069

    Re: Please help with this expression

    thanks got the idea...

     

    i have contructed this expression will just do a simple if and else statement

    \s{5}J\s.{22}\S.*


     white space, exactly 5 repititions
    J
    white space
    any character, exactly 22 repititions
    anything other than white space
    any character, any number of repititions 

    actually the sample i gave to you has 5 leading spaces
    and the position im looking is the 30th

     anyways thanks for the idea...
     

View as RSS news feed in XML