Click here to Skip to main content
15,394,463 members
Home / Discussions / Regular Expressions
   

Regular Expressions

 
GeneralRe: Pattern Pin
musefan4-Apr-11 2:55
Membermusefan4-Apr-11 2:55 
GeneralRe: Pattern Pin
Luc Pattyn4-Apr-11 3:38
sitebuilderLuc Pattyn4-Apr-11 3:38 
GeneralRe: Pattern Pin
musefan4-Apr-11 4:03
Membermusefan4-Apr-11 4:03 
AnswerRe: Pattern Pin
Shahan Ayyub23-Aug-11 11:13
MemberShahan Ayyub23-Aug-11 11:13 
QuestionRegex in DataAnnotations that can unmatch a input string containing not paired double quote " Pin
stevecwlee28-Feb-11 16:31
Memberstevecwlee28-Feb-11 16:31 
AnswerRe: Regex in DataAnnotations that can unmatch a input string containing not paired double quote " Pin
Captain Ketchup4-Apr-11 1:40
MemberCaptain Ketchup4-Apr-11 1:40 
Questionxml regex (for php) Pin
fdsfsa76f7sa611-Nov-10 9:12
Memberfdsfsa76f7sa611-Nov-10 9:12 
AnswerRe: xml regex (for php) Pin
AspDotNetDev11-Nov-10 10:28
protectorAspDotNetDev11-Nov-10 10:28 
You should be a little more clear about exactly what you are trying to do with that question mark, but here are some things to keep in mind...

If you have well formed XML, an XML parser is almost certainly the way to go. It might actually be faster than a regular expression. Unfortunately, I'm not familiar with PHP's XML parser, but you should take the time to familarize yourself with it.

Also, the question mark means "the preceding item is optional". Since the question mark is after an opening paren, there is nothing preceeding it, so I'm not exactly sure what you're after there. Depending on the regular expression engine you use, you can use a similar syntax for positive and negative lookaheads and lookbehinds, and you can use them for named groups. Or if you put a backslash to the left of the question mark, you'll escape it so it matches a literal question mark. But I'm not really sure what you're trying to do here. For example, if you were trying to get the query string value out of a URL, you could use a named group to grab it:
http://www\.google\.com\?(?<QUERY_STRING>.*)

Notice I use the question mark twice. The first time as a literal question mark and the second time as part of a named group. Here is another example:
http://www\.google\.com(?=\?)

That is a positive lookahead that ensures the character following the "m" is a question mark. But it doesn't actually grab the question mark as part of the pattern, it only ensures that the URL will match if that question mark exists in the right location. And of course, there is this use of the question mark:
http://www\.google\.com\??

That means the last question mark is optional. And then there is one more use of question marks (lazy matching rather than greedy matching) that goes like this:
\<img\>.*?\</img\>

I'll leave it up to you to figure out what that does if you are interested. One more thing, the less than and greater than signs have a special meaning in regular expressions. You may want to escape them by putting a backslash to the left of them.

GeneralRe: xml regex (for php) Pin
fdsfsa76f7sa611-Nov-10 11:08
Memberfdsfsa76f7sa611-Nov-10 11:08 
QuestionExpression needed Pin
Mazdak5-Sep-10 16:22
MemberMazdak5-Sep-10 16:22 
AnswerCross-post Pin
Luc Pattyn5-Sep-10 16:54
sitebuilderLuc Pattyn5-Sep-10 16:54 
AnswerRe: Expression needed Pin
OriginalGriff6-Sep-10 1:27
mveOriginalGriff6-Sep-10 1:27 
Questionhtml tag finder Pin
moein.serpico14-Aug-10 23:14
Membermoein.serpico14-Aug-10 23:14 
AnswerRe: html tag finder Pin
PIEBALDconsult15-Aug-10 8:19
professionalPIEBALDconsult15-Aug-10 8:19 
AnswerRe: html tag finder Pin
OriginalGriff15-Aug-10 8:31
mveOriginalGriff15-Aug-10 8:31 
GeneralRe: html tag finder Pin
AspDotNetDev26-Sep-10 9:29
protectorAspDotNetDev26-Sep-10 9:29 
AnswerRe: html tag finder Pin
AspDotNetDev26-Sep-10 9:28
protectorAspDotNetDev26-Sep-10 9:28 
AnswerRe: html tag finder Pin
Hiren solanki17-Dec-10 0:40
MemberHiren solanki17-Dec-10 0:40 
QuestionDifferences between matches with same RegEx [modified] Pin
RichardGrimmer6-Aug-10 0:00
MemberRichardGrimmer6-Aug-10 0:00 
AnswerRe: Differences between matches with same RegEx Pin
Peter_in_27806-Aug-10 2:22
professionalPeter_in_27806-Aug-10 2:22 
GeneralRe: Differences between matches with same RegEx - RESOLVED Pin
RichardGrimmer8-Aug-10 22:53
MemberRichardGrimmer8-Aug-10 22:53 
QuestionEven Expresso couldn't help me with this RegEx - Can You? Pin
Sonhospa30-Jul-10 7:19
MemberSonhospa30-Jul-10 7:19 
AnswerRe: Even Expresso couldn't help me with this RegEx - Can You? Pin
Luc Pattyn30-Jul-10 7:57
sitebuilderLuc Pattyn30-Jul-10 7:57 
NewsPartially resolved: Even Expresso couldn't help me with this RegEx - Can You? Pin
Sonhospa31-Jul-10 1:06
MemberSonhospa31-Jul-10 1:06 
GeneralRe: Partially resolved: Even Expresso couldn't help me with this RegEx - Can You? Pin
Luc Pattyn31-Jul-10 2:24
sitebuilderLuc Pattyn31-Jul-10 2:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.