• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 267
  • Last Modified:

Match one string but not another

Can anyone help me to write a regular expression that matches "ecard", but not "scorecard" (without the double quotes)

Many thanks
0
cjohnson300
Asked:
cjohnson300
1 Solution
 
ozoCommented:
\becard
0
 
NicksonKohCommented:
Try "^ecard". ^ indicates the match must start with e.
0
 
chiragypatilCommented:
"[\ ]ecard[\ ]"

gives exactly "ecard"

I'm trying to make it work for following conditions (which currently dont work):
ecard at the begining or end of the line.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
chiragypatilCommented:
got it!!!

"\b[e][c][a][r][d]\b"

hope this is what u wanted
0
 
cjohnson300Author Commented:
I selected this answer because it was the first and it had the desired results
0
 
chiragypatilCommented:
No problems as far as the solution works.
But i thaught my solution was more accurate.

I'm ok with any decision!
0
 
NicksonKohCommented:
I have to agree ozo's answer is most elegant!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now