Regular expressions question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Joseph Czapski

    Regular expressions question

    Hi. You know that special character \b (word border) that is handy to use
    because it does not eat a character that you might want to match to another
    piece of your expression? \b matches the start or finish of a string of
    word characters: letters, numbers, and _. Is there any way to match the
    border of an arbitrary set of characters, also without eating a character?
    For example, say I want to match to the beginning or end of a string of the
    letters A, S, D, or F.

    Thanks very much.

    Joe Czapski
    Boston, Mass.




  • Jim Gibson

    #2
    Re: Regular expressions question

    In article <y6ydnQns76U_KZ 7eRVn-1Q@comcast.com> , Joseph Czapski
    <joec@nnnot.com > wrote:
    [color=blue]
    > Hi. You know that special character \b (word border) that is handy to use
    > because it does not eat a character that you might want to match to another
    > piece of your expression? \b matches the start or finish of a string of
    > word characters: letters, numbers, and _. Is there any way to match the
    > border of an arbitrary set of characters, also without eating a character?
    > For example, say I want to match to the beginning or end of a string of the
    > letters A, S, D, or F.[/color]

    Your question doesn't make a lot of sense to me. The regex /[ASDF]+/
    will match one or more of those characters in consecutive positions in
    a string. The characters immediately before and after will not be one
    of ASDF. Can you give some examples of what you are trying to match,
    with some sample strings that match and some that do not?

    You can use "zero-width negative lookahead (?=...) and -behind (?!...)"
    assertions to customize what should precede and follow any match, if
    that helps.

    FYI: this newsgroup is defunct; try comp.lang.perl. misc in the future.


    ----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
    http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
    ---= East/West-Coast Server Farms - Total Privacy via Encryption =---

    Comment

    Working...