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
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
)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.