Regular Expression Pattern

Posted on 2005-04-16
Last Modified: 2008-02-26
How is a pattern that matches a semicolon (";") - followed by one or none spaces (" "), either in the beginning of the string, or in the beginning of a new line.

I have currently come up with "\n; ?", but that does not match a semicolon in the beginning of the whole string.
Question by:Joakim_
    LVL 10

    Expert Comment

    Which language are you using?
    LVL 2

    Author Comment

    ASP (VBScript).
    LVL 10

    Accepted Solution

    OK, the reason I asked was that some languages treat multiline text (text with newline characters in it) differently.

    Normally, ^ matches at the start of a string. In multiline text, it matches at the start of every line, unless the Multiline option is set for the Regex (I don't know how you set options for regex in ASP).

    If you only wanted to search at the start of the string (NOT every line) you could alter the multiline setting, or use the \A metacharacter.

    So, "^; " should do what you want.
    LVL 2

    Author Comment

    Thank you, I didn't know about that Multiline option, but now, I know how to set it.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    Add mobile access to browser application 3 109
    Batch file output 20 71
    countX 22 53
    countPairs challenge 7 39
    Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
    Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
    In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now