My REGEXproblem with tag "<B>"

Discussion in 'PHP' started by afimafis, Feb 18, 2012.

  1. #1
    hi,


    i need to trim html text by using regex.but i could not. i need your help

    "<B>bla1</B> <B>bla2</B> bla3 " ....... how do edit this htm text ? i need change it as "bla1 bla2 bla3"


    thanks
     
    afimafis, Feb 18, 2012 IP
  2. koko5

    koko5 Active Member

    Messages:
    394
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    70
    #2
    Hi,

    try this :
    $s="<B>bla1</B> <B>bla2</B> bla3 ";
    echo str_ireplace(array('<b>','</b>'),'',$s);
    
    PHP:
     
    koko5, Feb 18, 2012 IP
  3. afimafis

    afimafis Greenhorn

    Messages:
    90
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #3
    thanks koko5 , but i need to use pure regex codes
     
    afimafis, Feb 18, 2012 IP
  4. koko5

    koko5 Active Member

    Messages:
    394
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    70
    #4
    OK, please try the following :

    
    $s="<B>bla1</B> <B>bla2</B> bla3 ";
    echo preg_replace('#(\<b\>)(.*?)(\</b\>)#mi','$2',$s);
    
    PHP:
     
    koko5, Feb 18, 2012 IP
  5. afimafis

    afimafis Greenhorn

    Messages:
    90
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #5
    thanks again :) but i can not use php codes :(
     
    afimafis, Feb 18, 2012 IP
  6. bogi

    bogi Well-Known Member

    Messages:
    482
    Likes Received:
    16
    Best Answers:
    2
    Trophy Points:
    140
    #6
    Cannot use php codes? :O Why would you post your question in the php section then?
     
    bogi, Feb 18, 2012 IP
  7. afimafis

    afimafis Greenhorn

    Messages:
    90
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #7
    i know Bogi, but i could not find related subject. :(
     
    afimafis, Feb 18, 2012 IP
  8. ThePHPMaster

    ThePHPMaster Well-Known Member

    Messages:
    737
    Likes Received:
    52
    Best Answers:
    33
    Trophy Points:
    150
    #8
    What are you using to do the replace? Javascript, sed, ..?
     
    ThePHPMaster, Feb 18, 2012 IP
  9. afimafis

    afimafis Greenhorn

    Messages:
    90
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #9
    i just use 3 party software.


     
    afimafis, Feb 18, 2012 IP
  10. ogah

    ogah Member

    Messages:
    60
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    36
    #10
    use strip_tags
    all html tags will gone :)
     
    ogah, Mar 5, 2012 IP