Rob Rob - 1 year ago 51
PHP Question

Convert regular expressions to readable text

Is there a way in PHP, that you can convert the following regular expression



3.0, 3.1, 3.2, 3.3

Thank you for looking in to this :)

Sorry i was unclear :/
I want to read out XML, and show that on a web-page, and i want to show that to users.
In that XML, there is a regular expression like this one:


My question is: Can I convert a regular expression like the one above me, to a readeble text that the average user understands :)

So that the user sees this: 3.1, 3.2, 3.3, ...

And not this: 3.[0123] (this is an example, it can be every number).

Answer Source

You can use the or to make the regex a bit more readable.


Also note the escaping of .. The . is a special character in regex and means "any character" your regex as is would have allowed more than just 3.0, 3.1, 3.2, or 3.3. You also should use anchors to ensure that is the only value in the string. So a final version (without delimiters):