summaryrefslogtreecommitdiffstats
path: root/doc/man/man3/qregexp.3qt
diff options
context:
space:
mode:
Diffstat (limited to 'doc/man/man3/qregexp.3qt')
-rw-r--r--doc/man/man3/qregexp.3qt4
1 files changed, 2 insertions, 2 deletions
diff --git a/doc/man/man3/qregexp.3qt b/doc/man/man3/qregexp.3qt
index 73f961bd..54013861 100644
--- a/doc/man/man3/qregexp.3qt
+++ b/doc/man/man3/qregexp.3qt
@@ -151,7 +151,7 @@ Regexps are built up from expressions, quantifiers, and assertions. The simplest
.PP
Note that in general regexps cannot be used to check for balanced brackets or tags. For example if you want to match an opening html \fC<b>\fR and its closing \fC</b>\fR you can only use a regexp if you know that these tags are not nested; the html fragment, \fC<b>bold <b>bolder</b></b>\fR will not match as expected. If you know the maximum level of nesting it is possible to create a regexp that will match correctly, but for an unknown level of nesting, regexps will fail.
.PP
-We'll start by writing a regexp to match integers in the range 0 to 99. We will retquire at least one digit so we will start with \fB[0-9]{1,1}\fR which means match a digit exactly once. This regexp alone will match integers in the range 0 to 9. To match one or two digits we can increase the maximum number of occurrences so the regexp becomes \fB[0-9]{1,2}\fR meaning match a digit at least once and at most twice. However, this regexp as it stands will not match correctly. This regexp will match one or two digits \fIwithin\fR a string. To ensure that we match against the whole string we must use the anchor assertions. We need \fB^\fR (caret) which when it is the first character in the regexp means that the regexp must match from the beginning of the string. And we also need \fB$\fR (dollar) which when it is the last character in the regexp means that the regexp must match until the end of the string. So now our regexp is \fB^[0-9]{1,2}$\fR. Note that assertions, such as \fB^\fR and \fB$\fR, do not match any characters.
+We'll start by writing a regexp to match integers in the range 0 to 99. We will require at least one digit so we will start with \fB[0-9]{1,1}\fR which means match a digit exactly once. This regexp alone will match integers in the range 0 to 9. To match one or two digits we can increase the maximum number of occurrences so the regexp becomes \fB[0-9]{1,2}\fR meaning match a digit at least once and at most twice. However, this regexp as it stands will not match correctly. This regexp will match one or two digits \fIwithin\fR a string. To ensure that we match against the whole string we must use the anchor assertions. We need \fB^\fR (caret) which when it is the first character in the regexp means that the regexp must match from the beginning of the string. And we also need \fB$\fR (dollar) which when it is the last character in the regexp means that the regexp must match until the end of the string. So now our regexp is \fB^[0-9]{1,2}$\fR. Note that assertions, such as \fB^\fR and \fB$\fR, do not match any characters.
.PP
If you've seen regexps elsewhere they may have looked different from the ones above. This is because some sets of characters and some quantifiers are so common that they have special symbols to represent them. \fB[0-9]\fR can be replaced with the symbol \fB\\d\fR. The quantifier to match exactly one occurrence, \fB{1,1}\fR, can be replaced with the expression itself. This means that \fBx{1,1}\fR is exactly the same as \fBx\fR alone. So our 0 to 99 matcher could be written \fB^\\d{1,2}$\fR. Another way of writing it would be \fB^\\d\\d{0,1}$\fR, i.e. from the start of the string match a digit followed by zero or one digits. In practice most people would write it \fB^\\d\\d?$\fR. The \fB?\fR is a shorthand for the quantifier \fB{0,1}\fR, i.e. a minimum of no occurrences a maximum of one occurrence. This is used to make an expression optional. The regexp \fB^\\d\\d?$\fR means "from the beginning of the string match one digit followed by zero or one digits and then the end of the string".
.PP
@@ -285,7 +285,7 @@ Most of the character class abbreviations supported by Perl are supported by QRe
.PP
In QRegExp, apart from within character classes, \fC^\fR always signifies the start of the string, so carets must always be escaped unless used for that purpose. In Perl the meaning of caret varies automagically depending on where it occurs so escaping it is rarely necessary. The same applies to \fC$\fR which in QRegExp always signifies the end of the string.
.PP
-QRegExp's quantifiers are the same as Perl's greedy quantifiers. Non-greedy matching cannot be applied to individual quantifiers, but can be applied to all the quantifiers in the pattern. For example, to match the Perl regexp \fBro+?m\fR retquires:
+QRegExp's quantifiers are the same as Perl's greedy quantifiers. Non-greedy matching cannot be applied to individual quantifiers, but can be applied to all the quantifiers in the pattern. For example, to match the Perl regexp \fBro+?m\fR requires:
.PP
.nf
.br