sivaprasad9394
Occasional Collector

How to use the Regular Expression in Section Template HTML Channel?

Hello Team,

How can i use the regex to check for the specific patter string matches or not? Base on the value true i have to do some operation in the content of the page.

 

 

$CMS_SET(set_content)$$CMS_VALUE(st_text)$$CMS_END_SET$
					$CMS_SET(regexStr)$$CMS_VALUE("<\/ul>[\r\n]+<br>[\r\n]+<\/div>")$$CMS_END_SET$
					$CMS_SET(regexPattern,class("java.util.regex.Pattern").compile(java.util.regex.Pattern))$$CMS_END_SET$
					$CMS_SET(((class("java.util.regex.Matcher")matcher),regexPattern.matcher(inputStr))$$CMS_END_SET$

 

 

How to change the above code in Section template and usage of

if (matcher.matches()) { .....}

My HTML content, matches 2 in online regx websites,

Guest_Access ID is configured on the existing Bosch WLAN infrastructure in all eligible.
<br>
<ul>
<li>text1</li>
<li>tsdfsdfext2</li>
</ul>
<br>
</div>
</div>
Guest_Access ID is configured on the existing Bosch WLAN infrastructure in all eligible locations.
<br>
<ul>
<li>text1</li>
<li>text2</li>
</ul>
<br>
" This method is known as “reinforcement learning.” In this approach, the AI learns for itself which action is best in which situation. "
</div>
<br>
<ul>
<li>text1</li>
<li>text2</li>
</ul>
<br>
</div>

 

text_block_1.png

 

 

 

text_block_2.png

 

 

 

 

$CMS_SET(regexString)$$CMS_VALUE("</ul>[\n\r]<br>[\n\r]</div>")$$CMS_END_SET$
<><>$CMS_VALUE(class("java.util.regex.Pattern").matches(regexString.toString().trim,set_content.toString()))$

The above code return false in HTMl channel.

Thank you,

Siva

0 Kudos
2 Replies
sivaprasad9394
Occasional Collector

Hello Team,

Any one has any idea ? How to implement in First Spirit?

error_regx.png

 

 

HTML Channel:

$CMS_SET(set_content)$$CMS_VALUE(st_text)$$CMS_END_SET$
$CMS_SET(compilerPattern)$$CMS_VALUE(class("java.util.regex.Pattern").compile("</ul><br></div>"))$$CMS_END_SET$
$CMS_SET(matcher)$$CMS_VALUE(class("java.util.regex.Pattern").matcher(set_content.toString().trim()))$$CMS_END_SET$
$CMS_VALUE((class("java.util.regex.Matcher")matcher))$
$CMS_IF(matcher.find())$
$CMS_VALUE("YESSSSSS")$
$CMS_END_IF$

 

Thanks n Regards,

Siva

0 Kudos
sivaprasad9394
Occasional Collector

Below code is also not working,

$CMS_IF(set_content.toString().trim().endsWith("</ul><br></div>"))$
???? YES
$CMS_END_IF$

0 Kudos