$string() = “This is with admin charges”;
What I intend to do is to write down an X-Path with RegEx to return the statement above true in the sense that when $string contains “admin charge”, then the statement returns true.
See, the statement above can have the following keywords,
- admin && charge || charges
- administrative && charge || charges
- administration && charge || charges
See, all and all, the root keyword here is “admin” and “charge”.
Therefore, I would like to write a script that incorporates X-Path and RegEx in it.
The following is my approach so far,
contains(upper-case(normalize-space($string)), "ADMIN CHARGES")
This is still only matches exactly.
I researched, but mostly is to check for single keyword, like
contains(upper-case($string), "^[m/ADMIN CHARGE/]"
Thanks in advance
Regular expression functions are part of the XPATH 2.0 syntax.
However, PHP uses the libxml PHP extension to handle its XML Manipulation, which implements the XPATH 1.0 spec only.
This answer shows an alternative using the PHP/Java Bridge and Saxon. It’s probably the best option for the moment.
Using a XSLT 2.0 library, one could use the matches function. From TFM: