php - RegExp for capturing "headline" trigger words in textarea -



php - RegExp for capturing "headline" trigger words in textarea -

i'm trying write regexp php preg_split capture "headline" words in textarea im processing.

i want utilize resulting array improve formatting user , create streamlined in review posts.

$returnvalue = preg_split('/[^|\n]*[\t| ]*\b(pro|contra|conclusion)\b\:[\t| ]*/i', $data['review_text'], -1, preg_split_no_empty|preg_split_delim_capture);

this sample text input

intro line one, first part of array pro:pro:double pro 1, no space between pro: pro:double pro 2, space between pro: test pro:double pro 3, characters between pro: pro:double pro 4, linebreak betweem, should create empty pro entry contra: conclusion: lastly contra empty conclusion: contra: in row should not match! conclusion: test spaces between conclusion , : conclusion: conclusion prefixed space conclusion: conclusion prefixed tab conclusion: conclusion prefixed 2 tabs space between conclusion : conclusion has space between conclusion , : final line multiple line breaks in between, should part of lastly conclusion fragment

the result should consist of [0] intro line, 4 pro results (with delimiters), 1 contra (empty) , 7 conclusion results (with delimiters). contra should empty , final line should part of lastly conclusion

i'm trying match this

start of line, start of file zero or n occurrences of white space character any version of pro, contra or conclusion (ignoring upper/lower case) zero or n occurrences of white space character :

in order

first of all, [^|\n]* means 0 or more characters not pipe | or linebreak. [\t| ]* means 0 or more characters not tabulation or pipe | or space.

i guess want:

/\s*\b(pro|contra|conclusion):[\t ]*/i

php regex preg-split

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -