Get a string with HTML tags inside a larger string with ColdFusion regex -


i'm new regular expressions , use help.

i attempting use coldfusion rereplace scrape data , desired content.

this have far:

<cfoutput> #rereplace("remove please <p>make display please</p> remove please", "", "", "all")# </cfoutput> 

what regular expression take string , return "make display please"?

in order subtext longer string, need match need, capture need capturing group (...), , match rest of string end. replacement \1 back-reference references text captured capturing group.

so, use

#rereplace("remove please <p>make display please</p> remove please", ".*<p>(.*?)</p>.*", "\1", "all")# 

the regex matches:

  • .* - matches character newline beginning last </p>
  • <p> - literal <p>
  • (.*?) - 0 or more characters other newline symbol few possible (it means closest </p> here)
  • </p> - matches literal </p>
  • .* - matches rest of text end (no newlines).

to match newlines, use [\s\s] instead of ..


Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -