Regex help

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

    Regex help

    I need a regex pattern that will match a string starting with zero or
    one dot's. For example, ".string" and "string" should both match, but
    something like "estring" should not match. So far, I've tried the
    following:

    \.*string
    [.]{0,1}string
    [\.]{0,1}string
    [^a-zA-z0-9]{0,1}string

    and none of these do the job 100%. I'm also wondering if there might
    be a bug in the regex library i'm using - it's a 3rd party class that
    somebody before me found and implemented. I have the source code for
    the regexp class if necessary. Any help would be appreciated. Please
    reply to rey_dimayuga@ho tmail.com.
  • Eric J. Roode

    #2
    Re: Regex help

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    rey_dimayuga@ho tmail.com (rdimayuga) wrote in
    news:4b68b09f.0 309291644.12c8f a0b@posting.goo gle.com:
    [color=blue]
    > I need a regex pattern that will match a string starting with zero or
    > one dot's. For example, ".string" and "string" should both match, but
    > something like "estring" should not match. So far, I've tried the
    > following:
    >
    > \.*string
    > [.]{0,1}string
    > [\.]{0,1}string
    > [^a-zA-z0-9]{0,1}string
    >
    > and none of these do the job 100%. I'm also wondering if there might
    > be a bug in the regex library i'm using - it's a 3rd party class that
    > somebody before me found and implemented. I have the source code for
    > the regexp class if necessary. Any help would be appreciated.[/color]

    Well, if you're using a 3p regex library and not Perl's regexes, then who
    knows. I know Perl's regexes -- other regex languages vary widely.

    I would suggest, perhaps, that your regex needs to be anchored at the
    start of the string in order to work.

    [color=blue]
    > Please
    > reply to rey_dimayuga@ho tmail.com.[/color]

    Sorry, no. That's not how usenet works. Answers to questions are posted
    publicly so that all may benefit.

    Also, for your future reference, comp.lang.perl is a defunct newsgroup.
    You'll get a better response if you post to comp.lang.perl. misc; that's
    the newsgroup for general Perl questions.

    - --
    Eric
    $_ = reverse sort $ /. r , qw p ekca lre uJ reh
    ts p , map $ _. $ " , qw e p h tona e and print

    -----BEGIN PGP SIGNATURE-----
    Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

    iQA/AwUBP3q8sGPeouI eTNHoEQJE2wCfQR 4zi6kxp1ir24xnP chrsu0NIO0AnjFz
    Rp7DmsLiPBgIHDK rJ8fomcXv
    =/LtP
    -----END PGP SIGNATURE-----

    Comment

    Working...