Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Regex for a simple sentence.

Posted on 2007-04-08
4
Medium Priority
?
572 Views
Last Modified: 2012-05-05
Hi,

I've got the sentence "A duck is a bird" and I want to create a regular expression that will detect it from something like this:

^(A )[a-zA-Z0-9]\s\w(is a)[a-zA-Z0-9]$

So that should also work for the sentence "A kitten is a cat".  However, my regex doesn't work, where have I gone wrong?

Cheers,
Col.
0
Comment
Question by:whos_wee_dug
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
4 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 18873461
^(A )[a-zA-Z0-9]\s(is a)[a-zA-Z0-9]$
0
 
LVL 84

Expert Comment

by:ozo
ID: 18873463
^(A )[a-zA-Z0-9]\s(is a)\s[a-zA-Z0-9]$
0
 
LVL 84

Expert Comment

by:ozo
ID: 18873466
Sorry again,
^(A )[a-zA-Z0-9]+\s(is a)\s[a-zA-Z0-9]+$
0
 
LVL 84

Accepted Solution

by:
ozo earned 1000 total points
ID: 18873469
Or just
^A\s+\w+\s+is\s+a\s+\w+$
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Whatever be the reason, if you are working on web development side,  you will need day-today validation codes like email validation, date validation , IP address validation, phone validation on any of the edit page or say at the time of registration…
As most anyone who uses or has come across them can attest to, regular expressions (regex) are a complicated bit of magic. Packed so succinctly within their cryptic syntax lies a great deal of power. It's not the "take over the world" kind of power,…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question