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 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jul 2004
    Location
    France
    Posts
    141
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Regular Expression

    I would like to replace any string with this format :
    [any thing inside]

    to remove the text inside [] + the brackets

    thank you for your help

  • #2
    Regular Coder
    Join Date
    Oct 2004
    Posts
    256
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If you simply want to remove both the square brackets and the arbitrary content they enclose (allowing for multiline and case-insensitivity), this ought to do it:

    PHP Code:
    $string $your_text_source;
    $pattern '/\[((im).+)\]/';
    $replace '';

    preg_replace($pattern$replace$string); 

  • #3
    Regular Coder
    Join Date
    Jul 2004
    Location
    France
    Posts
    141
    Thanks
    0
    Thanked 0 Times in 0 Posts
    of course i am not using php but asp net
    but i shall try "/\[((im).+)\]/'"

    thank you


  •  

    Posting Permissions

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