cleanRegex

cleanRegex ( string regex , string _subject , string _postProcessing , int _numberOfMask ) : string

Return the mask of a regex.
Same than regex but with post processing to format the data.

Warning: it is tempting to generalize the use of functions starting with clean without asking too many questions. But this is a bad idea because you often lose the HTML tags. So, if you do a cleanSelect and then another one after, it won't work because the second one won't have any HTML to parse. Clean the data in the last step.

Example


data="Hello world" 
console(cleanRegex(/(?si)(w[a-z]+)/, data)) // -> world




See also

regex
regexAll
cleanRegexAll

Parameters

regex

The regular expression to apply on _code. See regex for the pattern. It is important to remember to put a mask (...) to capture a substring, because it is not the expression of the regex that will be returned but the sub-mask of number _numberOfMask. If you want the whole thing, make a mask around the whole expression.

_subject (optional)

The string in which regex will be searched. It doesn't have to be HTML code, you can put any kind of text in it. If null it is the page code in a FORPAGE script.

_postProcessing (optional)

How do you want to clean the output data? This property amounts to using a combination of cleaning functions.
• null or nothing = For unformatted generic texts. Equivalent to stripTags + standardizeText
• "description" or "d" = For texts formatted in HTML. Equivalent to standardizeText
• "price" or "p" = For the prices. Equivalent to htmlToPrice
• "number", "decimal", "float" or "n" = number with decimal (see number)
• "integer" or "i" = numeric integer (see number)
• "none" or "-" or "." or "0" = nothing
• Other avaliable post-processings : "xml", "url", "prestashop_category", "prestashop_manufacturer", "prestashop_supplier", "prestashop_feature", "prestashop_feature_value", "prestashop_attribute", "prestashop_combination"

_numberOfMask (optional)

Default:1. Place of the mask in the regex. Masks are defined by brackets. You can create many masks in regular expressions. To find out the mask number, count the number of opening parentheses from the left.
The value -1 is not available, use regexAll.