Got more questions? Find advice on: ASP | SQL | XML | Windows
in Search
Welcome to RegexAdvice Sign in | Join | Help

My regex is to hard for me :)

Last post 05-19-2008, 7:01 PM by Aussie Susan. 3 replies.
Sort Posts: Previous Next
  •  04-29-2008, 11:30 AM 41734

    My regex is to hard for me :)

    hi, all i read some articles on the website but didn't find what i wanted because i'm a bit novice in ereg.

    I spend 24h to find a solution and don't find it yet ;(

    i have this :

    $myvar="a..........b..........this0textherethis1..........c..........d..........e..........this0anothertextherethis1..........f..........this0athingthis1";


    and 1) i want to delete all that is between  this0---------this1  with a preg_replace but that replace all

    after 2) i can clean $myvar just with a str_replace on  this0 and this1

    to have

     $myvar="a..........b....................c..........d..........e....................f..........";

    I test with preg_match_all but i don't want a tab in output i just want myvar

    Is it possible to delete  all stuff that start with this0 and end with this1 ?

     Can somebody write all the regex expression for me (i'm novice)

    thanks a lot. 

     


     

     

  •  04-29-2008, 7:01 PM 41752 in reply to 41734

    Re: My regex is to hard for me :)

    In the 'Construction Advice' forum, there is a sticky note (http://regexadvice.com/forums/thread/41315.aspx) that says what information we need to properly answer questions. One of the items listed there is to get real examples of the text to be manipulated.

    In this case, I could tell you to use the pattern

    this0[a-z]+?this1

    with a blank replacement string, but I doubt if this will mean much, especially as you say that you are a beginner. There are many other things that can make this fail such as the case of the characters, what appears just before 'this0' and after 'this1', if the test between these two markers is really only alphabetic characters and so on.

    Susan 

  •  05-02-2008, 9:39 AM 41865 in reply to 41752

    Re: My regex is to hard for me :)

    Thanks a lot, i finally learn all the little property of easy regex and found a little solution with separator #[this0]....

    By and thanks for response. 

  •  05-19-2008, 7:01 PM 42396 in reply to 41865

    Re: My regex is to hard for me :)

    I'm not sure if you have posted exactly the pattern you are using (it doesn't make much sense compared to the original example you provided.

    Regardless, your use of the square brackets is a bit worrying as they define a character class which means that "[this0]" will match a SINGLE character that is one of the number 0, 's', 'i', 't' or 'h'. Given the original example this would be wrong of you  were really trying to match the 4 characters 'THIS' in that order.

    Susan 

View as RSS news feed in XML