• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 274
  • 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
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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