Regex help

R

rdimayuga

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 (e-mail address removed).
 
E

Eric J. Roode

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

(e-mail address removed) (rdimayuga) wrote in
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.

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.

Please
reply to (e-mail address removed).

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/AwUBP3q8sGPeouIeTNHoEQJE2wCfQR4zi6kxp1ir24xnPchrsu0NIO0AnjFz
Rp7DmsLiPBgIHDKrJ8fomcXv
=/LtP
-----END PGP SIGNATURE-----
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top