I have functions and placed inside of html code. These functions has this following syntax rules:
This is not my real function but it give the whole ideas of rules above:
<html>
#v123w(r(!@3o=?w){
<div></div>
}#
#131ie_w(13gf$>&*()(*&){
<div></div>
}#
</html>
All this time, I'm using this regex to capture the all of the function names, parameters, and the html strings inside functions:
#(\w+)\(*([\w\d\s\=\>\<\[\]\"\'\)\(\&\|\*\+\-\%\@\^\?\/\$\.\!]*)\)\)*{((?:(?R)|.)*?)}#
This is the result:
You can see the detail in regex tester: https://regex101.com/r/HdCeeV/1
Currently I found that preg_match_all function in php does not work for a long string. Thus, I cannot use this regex if the html code inside the function is too long. I need to capture the function name, function parameter, and html string inside the function. Is there any alternative for this regex? Maybe using PHP file function like substr, strpos, etc?
Here is an improvement of your regex, a little bit more efficient:
#(\w+)\(([\w\s=><[\]"')(&|*+%@^?\/$.!-]*)\){(.+?)}#