2012-04-03 5 views
0

현재이 문자열은 내가 가지고있는 preg_replace 문자열입니다.regex에서 다른 문자로 바꾸기 PHP

$mtg_post['post_content'] = preg_replace("[^\\x20-\\x7e]", "",$ability); 

이것은 $ 능력 내에 포함 된 데이터의 예입니다.

At the beginning of your upkeep, put a doom counter on Armageddon Clock.£At the 
beginning of your draw step, Armageddon Clock deals damage equal to the number 
of doom counters on it to each player.£{4}: Remove a doom counter from Armageddon 
Clock. Any player may activate this ability but only during any upkeep step. 

£ 문자를 2xreturn 또는 새 단락으로 바꾸시겠습니까? regex 그래서 라인을 이렇게 보이지만 꽤 확실하지 구현하는 방법.

At the beginning of your upkeep, put a doom counter on Armageddon Clock. 

At the beginning of your draw step, Armageddon Clock deals damage equal 
to the number of doom counters on it to each player. 

{4}: Remove a doom counter from Armageddon Clock. Any player may activate 
    this ability but only during any upkeep step. 

답변

3

여기에 정규 표현식에 대한 필요가 없습니다, 단지 str_replace()를 사용

$out = str_replace("£", "\n\n", $in); 
+0

이 그들에 £ 한 전체 라인을 삭제합니다. –

+0

나를위한 것이 아니며 말이 될 수도 없습니다. 여기에 데모가 있습니다 : http://codepad.org/oho8zhgi – Cal

+0

그래, 나는 수동으로 변수로 텍스트를 넣고 전체 라인을 제거합니다. 여기 풀 코드에 대한 링크가 있습니다. http://codepad.org/DupoYKzY –

관련 문제