• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!
Collapse

You are not logged in or you do not have permission to access this page. This could be due to one of several reasons:

  • You are not logged in. If you are already registered, fill in the form below to log in, or follow the "Sign Up" link to register a new account.
  • You may not have sufficient privileges to access this page. Are you trying to edit someone else's post, access administrative features or some other privileged system?
  • If you are trying to post, the administrator may have disabled your account, or it may be awaiting activation.

Previously on "Regular Expressions"

Collapse

  • Guest's Avatar
    Guest replied
    oops my fault, confused VBScript with JScript (aka JavaScript).

    Leave a comment:


  • Guest's Avatar
    Guest replied
    Not sure where Javascript has crept into this. I am using VB6 and referencing the "Microsoft VBScript Regular Expressions" class.

    The documentation on this does list the match and capture pattern () but does not appear to work.

    Leave a comment:


  • Guest's Avatar
    Guest replied
    RegExps are part of JavaScript since v1.3 (or v1.4 more like it --never had to use them in JS). Previously you could use Java for it, but it was really messy and crappy.

    Leave a comment:


  • Guest's Avatar
    Guest replied
    Thanks for the info. Sorry for the delay in getting back - day off today for 3yr old daughter's birthday.

    PerlOfWisdom - The pattern you showed was similar to the one I thought and tried but to no avail. I am beginning to think that the VBScript class does not support the () part of regular expressions (although the documentation states otherwise). I have pasted examples from the net and books and it fails to work on every occasion. I tried this using .Net regular expressions and it worked a dream.

    AtW - I appreciate that using a regular expression may not have been the ideal way of doing this. However, sometimes the way to get ones head around a new technique is to put it to effect in a practical circumstance rather than a contrived one. I wasn't sure if I would have implemented the final solution using a regular expression but was using it as a learning exercise.

    Leave a comment:


  • Guest's Avatar
    Guest replied
    > I am receiving in a message a fixed length fixed format
    > string.

    substring works fine for this sort of tasks, less overhead, especially in VBscript.

    note: I love perl and reg exps but sometimes substring is just fine.

    Leave a comment:


  • Guest's Avatar
    Guest replied
    This code fragment works in Perl, don't know that much about javascript.


    $string = "0123456789ab";

    $string =~ /^([A-Z0-9]{4})([A-Z0-9]{3})([A-Z0-9]{5})/i;

    print "$1, $2, $3\n";

    Leave a comment:


  • Guest's Avatar
    Guest started a topic Regular Expressions

    Regular Expressions

    Just starting (hopefully) to get my head around regular expressions when I have come across a real life problem where I am not sure if they can be utilised.

    I am receiving in a message a fixed length fixed format string. I wondered if I could use a regular expression to easily extract the information. I know I can do it by straightforward string manipulation but I thought I may have an opportunity to use regular expressions.

    e.g. "AAAABBBCCCCC"
    I would like a regular expression that produced a match collection containing
    AAAA
    BBB
    CCCCC

    where A,B and C are any alphanumeric character. I need to extract the first 4 characters as the first match, the next 3 as the second, the next 5 asthe third and so on.

    I am using the RegExp class provided by VBScript, in case that has any relevance to a possible solution.

    TIA
Working...
X