regexeclipsecoldfusioncfeclipse

Regular Expression based search in CFEClipse for tags not containing an attribute


I've got a few regular expressions down pat, but am struggling within CFEclipse to nail the syntax which finds:

all instances of the cfquery tag that don't contain the attribute name

I've tried

<cfquery [^>]*(?!(name=))[^>]*>

which I'd intended to trap:

the cfquery tag, followed by any number of characters that aren't the closing >, NOT followed by the name attribute, followed by any number of characters that aren't the closing >, followed by the closing >.

This finds plenty of matches, the some of which do contain the name attribute and some of which don't (so it's obviously incorrect).

Can anyone hit me with a clue stick on this one? Thanks!


Solution

  • It looks like you should be using an XML parser for this, but your issue is that [^>]* is greedy and will match through the name attribute if it exists. You need something like the following:

    <cfquery (?![^>]*name=)[^>]*>
    

    By moving the [^>]* into the negative lookahead you can make sure that "name=" does not exist in the string before the next >.