Jump to content

what's causing this lookahead to fail?


bitt3n

Recommended Posts

in the following, I want put only 'Capitalized Words' into a group.

 

text="ALL CAPITAL LETTERS - Capitalized Words"

 

the best way to do it seems to use the logic: "match everything until the following character is lowercase, then put the current and following characters in a group, stopping at the final quotation mark"

 

to do this I've tried

 

text="(.(?![a-z]))+(?<mygroup>[^"]+)"

 

which I understand to mean "match at least one of anything that isn't followed by a lowercase character, then make the group"

 

however I've clearly screwed something up. What did I do wrong?

Link to comment
https://forums.phpfreaks.com/topic/244868-whats-causing-this-lookahead-to-fail/
Share on other sites

maybe need to rephrase or give more explanation or more context or somethin' because as-is, your regex works, in that you get "Capitalized Words" in "mygroup"

 

Array
(
    [0] => text="ALL CAPITAL LETTERS - Capitalized Words"
    [1] =>  
    [mygroup] => Capitalized Words
    [2] => Capitalized Words
)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.