Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5

Thread: RegEx help

  1. #1
    Senior Coder gsnedders's Avatar
    Join Date
    Jan 2004
    Posts
    2,340
    Thanks
    1
    Thanked 7 Times in 7 Posts

    RegEx help

    I've managed to get this:
    PHP Code:
    echo preg_replace('/<(\S):(\S)(.*)>/msiU''<\\2\\3>''<blah:blah test="test: this">'); 
    However, that doesn't remove anything. What it should output is:
    Code:
    <blah test="test: this">

  • #2
    fci
    fci is offline
    Senior Coder
    Join Date
    Aug 2004
    Location
    Twin Cities
    Posts
    1,345
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    echo preg_replace('/<(?:[a-zA-Z]+:)/m', '<', '<blah:blah test="test: this">');
    remember to use htmlentities so your browser doesn't render while testing (or view the source).
    Last edited by fci; 02-16-2006 at 07:26 PM.

  • #3
    Senior Coder gsnedders's Avatar
    Join Date
    Jan 2004
    Posts
    2,340
    Thanks
    1
    Thanked 7 Times in 7 Posts
    What does that "?:" do?

  • #4
    fci
    fci is offline
    Senior Coder
    Join Date
    Aug 2004
    Location
    Twin Cities
    Posts
    1,345
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Error 404
    What does that "?:" do?
    it means it is non capturing unlike just using normal parentheses(capturing) which will give you the \1 and so on.

  • #5
    Senior Coder gsnedders's Avatar
    Join Date
    Jan 2004
    Posts
    2,340
    Thanks
    1
    Thanked 7 Times in 7 Posts
    Ah, OK. Thanks.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •