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

Problem with ?= , ^ and $ in VBScript

Last post 06-27-2008, 3:59 PM by mash. 7 replies.
Sort Posts: Previous Next
  •  05-14-2008, 11:17 PM 42269

    Problem with ?= , ^ and $ in VBScript


    Hello, I'm sorry if someone asked this before. But when I search the 4rum with keyword "?=", it turn to nothing.

    I'm RegExp newbie, I'm using ASP VBScript and I'm wonder how they use the (?=) in the pattern
    In detail, I have the string :

    HH=1:2:3  /  BQ=X:Y:Z  /  G  /   3=dd:aa           ---->> I wanna get out :   HH , BQ ,  G , 3
    or
    A=1:R:7  /   CV=G  /  TT                                 ----->> I wanna get :   A , CV , TT

    (The spaces is only for easier viewing, the string contains no space indeed)   Please notice the separator : (/) (=) and (:)

    with the type of strings beyond, I used the pattern :

    ( / ( \ w + ) ( ? = [ / = ] ) )        (Plz ignore all the space character)

    This worked good, but it return the slash preceding the result ( like   / HH )

    I wanna remove the slash then I changed it to :

    ( ? = \ / ) ( \ w + ) ( ? = [ / = ] ) )

    The result was 4 zero length string . Can you tell me what happened and the solution ?
    -------
    BTW , could you show me how to search for "formula keyword" like    "?="
    I searched Google and RegexAdvice with the same keyword but no result !
  •  05-15-2008, 12:36 AM 42275 in reply to 42269

    Re: Problem with ?= , ^ and $ in VBScript

    In the future please do reformat your data when posting. It is not helpful. If someone wanted to run a test against your sample they would have to edit it. Post the actual text as requested in the posting guidelines.

    As to your pattern I don't think it matches anything. VBScript may be returning empty strings to whatever you are calling. The \w alone would have to match one character so you should not be able return an empty sting as a match. You can't use the lookahead the way you are trying to at the begining of your pattern.  Lookahead do not consume any characters.  You are trying to examine a character behind the one you want. There is a regex construct for doing this but it is not supported by VBScript. Your lookahead at the end of your pattern is the proper use.

    You could just use the regex that was working for you and get the value you want out of the SubMatches.  http://regexadvice.com/blogs/mash/archive/2007/06/01/You_2700_ve-got-your-sub_2D00_matches-in-my-matches.aspx


    Michael

    "In theory, theory and practice are the same. In practice, they are not."
    Albert Einstein
  •  05-15-2008, 2:24 AM 42280 in reply to 42275

    Re: Problem with ?= , ^ and $ in VBScript


    Hi Mash, thanks for reply.
    I've read your article, and found (I think) nothing useful for my situation.
    Yeah, VBScript doesn't support (?=) preceding a pattern, but I've just found VBScipt has the structure :  (?:
    Could you tell me the differences ?

    BTW, is using Regex slow down my application ?

  •  05-15-2008, 3:06 AM 42281 in reply to 42280

    Re: Problem with ?= , ^ and $ in VBScript


    Yah, I've found the solution with SubMatches ! And I've found the new word "needless grief" too :)) Thank you again (a giant ) ^__^

    Maybe, my question is quite basic, but it's hard to search the net with very complex word like "?=" or "?:".
    Have u got some experience when searching such a word ?
  •  05-15-2008, 4:14 AM 42290 in reply to 42281

    Re: Problem with ?= , ^ and $ in VBScript

    This is where I would recommend you start:

    http://www.regular-expressions.info/

    It has sections on the various regex constructs as well as a section on what vbscript does and does not support.


  •  06-27-2008, 3:49 PM 43550 in reply to 42275

    Re: Problem with ?= , ^ and $ in VBScript

    Hey,

     

    I have very basic problem. I want a Regex to validate a fieldvalue which should either be of 11 digits or 15 digits.

     I am using "\d{11}|\d{15}" as pattern but the problem is it gives values as "VALID" if they contain 11 or > 11 digits, gives invalid only in case where digits are less than 11.

     

    Please help...

    Filed under:
  •  06-27-2008, 3:54 PM 43551 in reply to 43550

    Re: Problem with ?= , ^ and $ in VBScript

    gur, please start a new message thread if your post is not in response to the original thread.

    but, here's a pattern for you to test:

    "^(\d{11}|\d{15})$"


  •  06-27-2008, 3:59 PM 43552 in reply to 43550

    Re: Problem with ?= , ^ and $ in VBScript

    In the future start your own post.  Don't hijack someone else's. 

    Just reverse the order of your test, and add boundards. What you have simple say finds x number of consecutive digits somewhere in a string.


    Michael

    "In theory, theory and practice are the same. In practice, they are not."
    Albert Einstein
View as RSS news feed in XML