preg_replace failing on new line, unsure best way to fix

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • fade2k
    New Member
    • Jun 2012
    • 1

    preg_replace failing on new line, unsure best way to fix

    My first post/question here so I hope the title was specific enough for this issue. Did a search but didn't find what I was looking for.

    The problem: When using preg_replace to replace items it works unless there is a new line right after the items.

    IE: !username
    !username (without spaces)

    This is what I have:
    $text = preg_replace('/[!]+('.$value.'+)/',$profileLink, $text);

    It works when there IS a space though.

    Is there a way to fix it IN the preg_replace or should I replace new lines with new lines with a space wrapped around them?
Working...