Ok I agree with dropping the first 4 characters (I was thinking that the ?
after the .* would allow it to have something or nothing before the
CREDI).
The (T ?)? is saying that I could have a 'T', or a 'T ' or neither (CREDIT
LINKS, CREDILINKS, CREDITLINKS) and all that works well. The LINKS could
be spelled LINKS, LYNKS, LINK, LYNK, LINX, LYNX.
The last group '((?!CAN|\bCA\b).)*$' is supposed to say if after the
CREDI... there is CAN anywhere or CA in a word, then the expression is not
valid. As I said the expression works in a REGEX validation program I have
on the PC, but when I put the same expression on the i5, it fails with the
message I listed. If I remove the '((?!CAN|\bCA\b).)*$' then the
expression compiles.
I can always create 2 expressions one where it finds the CAN|\bCA\b that
I then flag as invalid, then another less restrictive one that I flag as
valid. It would test the first and if matched, get out returning invalid,
otherwise go to the next.
Matt Hopkins
Sr. Programmer/Analyst
Web: www.pdpgroupinc.com
Email: MWHopkins@xxxxxxxxxxxxxxx
Office: 410-584-0330
Fax: 410-584-0336
Cell: 410-258-8845
From: "Dennis Lovelady" <iseries@xxxxxxxxxxxx>
To: "'Midrange Systems Technical Discussion'"
<midrange-l@xxxxxxxxxxxx>
Date: 04/14/2010 05:40 PM
Subject: RE: Regular expression not valid on i
Sent by: midrange-l-bounces@xxxxxxxxxxxx
system. When the regcomp() process runs on the i5 I get the message: "?,
*
or + not preceded by valid regular expression." The Regex Coach says it
is
valid and is finding the strings I want it to.
The regex I am trying to use is:
^.*?CREDI(T ?)?L(I|Y)(NX|NK|NKS)((?!CAN|\bca\b).)*$
First off, I would drop the beginning three characters ^.* since the
statement executes the same with and without them. (You are saying,
"Anchor
to the beginning of the line, then skip as many as necessary until you
find..." The regex will do that anyway if you don't anchor.)
That leaves you with an expression that starts with a question mark. The
question mark meaning is "Zero or more of the PRECEDING element. (not
meant
as a shout.) There is no preceding element. After that I see several
other
similar uses of ? and I'm fairly certain you're misunderstanding that
purpose. You might want to start with the wiki on the topic, which is
pretty easy to read and understand.
http://en.wikipedia.org/wiki/Regular_expression.
I think you don't want us to write the expression so I will leave you with
that and offer my help with questions.
Dennis Lovelady
http://www.linkedin.com/in/dennislovelady
--
"I found your essay to be good and original. However, the part that was
original was not good and the part that was good was not original."
-- Samuel Johnson
As an Amazon Associate we earn from qualifying purchases.