WordPress.org

Ready to get started?Download WordPress

Forums

regular expression problem for IE (4 posts)

  1. geoffe
    Member
    Posted 8 years ago #

    This happens only in Internet Explorer but the javascript function sendToEditor() in inline-uploading.php doesn't execute well in IE, while FF processes it fine.

    For example, this command

    h = h.replace(new RegExp(' (class|title|width|height|id|onclick|onmousedown)=([^\'"][^ ]*)( |/|>)', 'g'), ' $1="$2"$3'); // Enclose attribs in quotes

    will replace <div id=photoinlayer><img src=file.jpg ...
    as <div id="photoinlayer"><img src="file.jpg" ... in Firefox but IE will produce
    <div id="photoinlayer><img" src="file.jpg...

    So it appears that the conditions ([^\'"][^ ]*)( |/|>) aren't working properly in IE.

    Any ideas why?

  2. geoffe
    Member
    Posted 8 years ago #

    can anyone tell me what this translates to in the search: [^\'"][^ ]*

    I'm reading this but not getting it.

    edit: I've figured out that the above set means any character that is not ' or " followed by any character that is not a space. Any chance IE doesn't understand that? Or a tip on where I can find help on this?

    edit2: using ([^\'"][^ ]+?) seems to fix the problem for IE.

    Can anyone tell me if this is a valid solution, or why it should or shouldn't be used?

  3. geoffe
    Member
    Posted 8 years ago #

    That fixed the trouble, although I had to separate the search for id and add it as a second replace.

    I still can't figure out how to get
    h = h.replace(new RegExp('<(/?)A', 'g'), '<$1a'); // Lowercase tagnames

    to work in IE.

  4. geoffe
    Member
    Posted 8 years ago #

    I've also found a place for help with Regex on this topic. Hopefully some solution will come of this.

Topic Closed

This topic has been closed to new replies.

About this Topic