A string containing one P character:
- a (possibly empty) string containing non-P characters
- a P
- a (possibly empty) string containing non-P characters
In regex format, this is:
^[^P]*P[^P]*$
Where:
^ matches the beginning of a line[^P]* matches any character other than P, 0 or more timesP corresponds to P[^P]* matches any character other than P, 0 or more times$ matches end of line
The difference between [^P*]and [^P]*is:
[^P*] matches any single character that is neither P nor *[^P]* matches zero or more characters that are not P
*, , . [] * . [] * " ".