#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2003
    Location
    London
    Posts
    1
    Rep Power
    0

    Question Regular expression required


    Any regular expressions experts out there that can help me out with a quick query...

    Am using an iframe 'rich text editor' for a CMS and have written a function for pasting from Word that strips out all the rubbish MS tags - but I'm still left with the following empty tag...
    Code:
    <p> </p>
    There's a space in between the opening and closing tags

    Am not a regex expert and just can't quite find the right regex pattern to match with in the javascript replace to get rid of this.

    Any help greatly appreciated.

    Thanks

    dominicall
  2. #2
  3. Thanks Johnny Hart (BC) R.I.P.

    Join Date
    May 2003
    Location
    Dallas
    Posts
    5,268
    Rep Power
    1956
    Code:
    s/<p> <\/p>//g
    
    or
    
    s/<p>\ <\/p>//g
    The above should work in the general case to remove the <p> </p> tag set. Note that one version escapes the space, needed for some dialects.

    To just remove the space,
    Code:
    s/<p> <\/p>/<p><\/p>/g
    The trailing 'g' sz do all sets in a line. Some mods may be needed to match the js dialect.

    cheers,

    gary
    There are those who manage to build a web site without knowing what they're doing; thereby proving to themselves they do, indeed, know what they're doing.

    My html and css workshop, demos and tutorials.
    Ask a better question, get a better answer.

IMN logo majestic logo threadwatch logo seochat tools logo