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


I am trying to write a regexp for a "php preg_split" so that some text like "headline" Be captured

I want to use the resulting array to improve the formatting for the user and I want to create a streamlined view in the review posts. Prev_split ('/ [^ | N] * [\ t |] * \ b (Pro | Contra | Conclusion) \ b \: [\ t |] * / i ', $ Data [' review_text '], -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);

This is my sample text input

  Introduction line one, the first part of the array Pro: Pro: Double Pro 1, no space between Pro: Pro: Pro: Pro: Between Pro, Pro: Pro Pro: Double Pro 2, Between Space, Pro Space: Should create blank Pro entry Contra: Conclusion: Last Contra was empty Conclusion: This Contra : These should not match this line! Conclusion: Test with spaces between the conclusions: Conclusions: The conclusion was prefixed by a space conclusion: This conclusion was prefixed by a tab conclusion: the conclusion was a space between the conclusions by two tabs: this conclusion There is a space between the conclusions and:   

In this case [0] should be in the form of identification line, 4 Pro results (with their delimiter), 1 conte (Empty) and 7 result results (with their delimiter). Only the Contra should be empty and the last line should be a part of the final conclusion

I am trying to make some matches like this

  1. The beginning of the line, the start of the file
  2. Zero or n incidents of any white space character
  3. Any version of Pro, Contra or Conclusion (ignoring upper / lower case)
  4. Void Or any of the events of the N are white space characters
  5. :

    In this order

    First of all, [^ | \ n] * It means 0 or more characters which is the pipe | or the line breaks are not.
    [\ t | ] * 0 or more characters that are tabulation or pipe | or no place

    I think you want:

      / \ S * \ b (Pro | Contra | conclusion): [\ t] * / i    

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -