View Single Post
Old 06-18-2015, 03:43 PM   #3
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 28,645
Karma: 204624552
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
I think she's trying to use the question mark to make the entire group (within the parens) optional.

@Terisa: While your regex should match (it does for me when I use it in other applications), the question mark (as well the space inside the group) is probably not necessary. The * is already 0 or more repetitions, which implies that what precedes it is "optional."

When you say "goes wrong," do you mean you want your expression to match the code example you gave, or you don't want it to match?

Something like:
Code:
<div><p([^>]*)>
Should be sufficient to match any p tag that immediately follows a div tag-- regardless if the p tag has any attributes or not.

If you're looking for something else, you'll need to clarify.

Last edited by DiapDealer; 06-18-2015 at 03:48 PM.
DiapDealer is offline   Reply With Quote