Search regular expressions

Product Compare Forums Multi-Edit Support Search regular expressions

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #2832
    MikeScholl
    Participant

    I wanted to seach for img tags that don’t have an alt attribute. But if I search for img[~alt]*> it looks for img followed by any character other than a,l or t. Is there a regex that would do what I want?

    Mike

    #9170
    Clay Martin
    Keymaster

    Hi,
    Yes you are right, the [] construct matches individual characters. There is no way with the unix style regular expressions to match a phrase that is not there. You may be able to do this with pearl regular expressions (using (alt=){0}), but I am not very familiar with them, and had no luck on my initial efforts.

    Thanks,
    Clay

    #9169
    daantje
    Participant

    Hi,

    Use the perl regular expression with a negative look ahead. A good starter may be: [code:328fhita]<img\s(?!.*alt=.*?)[/code:328fhita]

    Daniƫl

    #9171
    MikeScholl
    Participant

    Thanks Daniel, that seems to do the trick. My HTML validator complains when I don’t put in alt text so now I can find them all!!

    Mike

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.