[][src]Struct qt_core::QRegExp

#[repr(C)]
pub struct QRegExp { /* fields omitted */ }

The QRegExp class provides pattern matching using regular expressions.

C++ class: QRegExp.

C++ documentation:

The QRegExp class provides pattern matching using regular expressions.

A regular expression, or "regexp", is a pattern for matching substrings in a text. This is useful in many contexts, e.g.,

ValidationA regexp can test whether a substring meets some criteria, e.g. is an integer or contains no whitespace.
SearchingA regexp provides more powerful pattern matching than simple substring matching, e.g., match one of the words mail, letter or correspondence, but none of the words email, mailman, mailer, letterbox, etc.
Search and ReplaceA regexp can replace all occurrences of a substring with a different substring, e.g., replace all occurrences of & with & except where the & is already followed by an amp;.
String SplittingA regexp can be used to identify where a string should be split apart, e.g. splitting tab-delimited strings.

A brief introduction to regexps is presented, a description of Qt's regexp language, some examples, and the function documentation itself. QRegExp is modeled on Perl's regexp language. It fully supports Unicode. QRegExp can also be used in a simpler, wildcard mode that is similar to the functionality found in command shells. The syntax rules used by QRegExp can be changed with setPatternSyntax(). In particular, the pattern syntax can be set to QRegExp::FixedString, which means the pattern to be matched is interpreted as a plain string, i.e., special characters (e.g., backslash) are not escaped.

A good text on regexps is Mastering Regular Expressions (Third Edition) by Jeffrey E. F. Friedl, ISBN 0-596-52812-4.

Note: In Qt 5, the new QRegularExpression class provides a Perl compatible implementation of regular expressions and is recommended in place of QRegExp.

Methods

impl QRegExp[src]

pub unsafe fn cap_1a(&self, nth: c_int) -> CppBox<QString>[src]

Returns the text captured by the nth subexpression. The entire match has index 0 and the parenthesized subexpressions have indexes starting from 1 (excluding non-capturing parentheses).

Calls C++ function: QString QRegExp::cap(int nth = …) const.

C++ documentation:

Returns the text captured by the nth subexpression. The entire match has index 0 and the parenthesized subexpressions have indexes starting from 1 (excluding non-capturing parentheses).


  QRegExp rxlen("(\\d+)(?:\\s*)(cm|inch)");
  int pos = rxlen.indexIn("Length: 189cm");
  if (pos > -1) {
      QString value = rxlen.cap(1); // "189"
      QString unit = rxlen.cap(2);  // "cm"
      // ...
  }

The order of elements matched by cap() is as follows. The first element, cap(0), is the entire matching string. Each subsequent element corresponds to the next capturing open left parentheses. Thus cap(1) is the text of the first capturing parentheses, cap(2) is the text of the second, and so on.

See also capturedTexts() and pos().

pub unsafe fn cap_1a_mut(&mut self, nth: c_int) -> CppBox<QString>[src]

Returns the text captured by the nth subexpression. The entire match has index 0 and the parenthesized subexpressions have indexes starting from 1 (excluding non-capturing parentheses).

Calls C++ function: QString QRegExp::cap(int nth = …).

C++ documentation:

Returns the text captured by the nth subexpression. The entire match has index 0 and the parenthesized subexpressions have indexes starting from 1 (excluding non-capturing parentheses).


  QRegExp rxlen("(\\d+)(?:\\s*)(cm|inch)");
  int pos = rxlen.indexIn("Length: 189cm");
  if (pos > -1) {
      QString value = rxlen.cap(1); // "189"
      QString unit = rxlen.cap(2);  // "cm"
      // ...
  }

The order of elements matched by cap() is as follows. The first element, cap(0), is the entire matching string. Each subsequent element corresponds to the next capturing open left parentheses. Thus cap(1) is the text of the first capturing parentheses, cap(2) is the text of the second, and so on.

See also capturedTexts() and pos().

pub unsafe fn cap_0a(&self) -> CppBox<QString>[src]

Returns the text captured by the nth subexpression. The entire match has index 0 and the parenthesized subexpressions have indexes starting from 1 (excluding non-capturing parentheses).

Calls C++ function: QString QRegExp::cap() const.

C++ documentation:

Returns the text captured by the nth subexpression. The entire match has index 0 and the parenthesized subexpressions have indexes starting from 1 (excluding non-capturing parentheses).


  QRegExp rxlen("(\\d+)(?:\\s*)(cm|inch)");
  int pos = rxlen.indexIn("Length: 189cm");
  if (pos > -1) {
      QString value = rxlen.cap(1); // "189"
      QString unit = rxlen.cap(2);  // "cm"
      // ...
  }

The order of elements matched by cap() is as follows. The first element, cap(0), is the entire matching string. Each subsequent element corresponds to the next capturing open left parentheses. Thus cap(1) is the text of the first capturing parentheses, cap(2) is the text of the second, and so on.

See also capturedTexts() and pos().

pub unsafe fn cap_0a_mut(&mut self) -> CppBox<QString>[src]

Returns the text captured by the nth subexpression. The entire match has index 0 and the parenthesized subexpressions have indexes starting from 1 (excluding non-capturing parentheses).

Calls C++ function: QString QRegExp::cap().

C++ documentation:

Returns the text captured by the nth subexpression. The entire match has index 0 and the parenthesized subexpressions have indexes starting from 1 (excluding non-capturing parentheses).


  QRegExp rxlen("(\\d+)(?:\\s*)(cm|inch)");
  int pos = rxlen.indexIn("Length: 189cm");
  if (pos > -1) {
      QString value = rxlen.cap(1); // "189"
      QString unit = rxlen.cap(2);  // "cm"
      // ...
  }

The order of elements matched by cap() is as follows. The first element, cap(0), is the entire matching string. Each subsequent element corresponds to the next capturing open left parentheses. Thus cap(1) is the text of the first capturing parentheses, cap(2) is the text of the second, and so on.

See also capturedTexts() and pos().

pub unsafe fn capture_count(&self) -> c_int[src]

Returns the number of captures contained in the regular expression.

Calls C++ function: int QRegExp::captureCount() const.

C++ documentation:

Returns the number of captures contained in the regular expression.

This function was introduced in Qt 4.6.

pub unsafe fn captured_texts(&self) -> CppBox<QStringList>[src]

Returns a list of the captured text strings.

Calls C++ function: QStringList QRegExp::capturedTexts() const.

C++ documentation:

Returns a list of the captured text strings.

The first string in the list is the entire matched string. Each subsequent list element contains a string that matched a (capturing) subexpression of the regexp.

For example:

QRegExp rx("(\d+)(\s*)(cm|inch(es)?)"); int pos = rx.indexIn("Length: 36 inches"); QStringList list = rx.capturedTexts(); // list is now ("36 inches", "36", " ", "inches", "es")

The above example also captures elements that may be present but which we have no interest in. This problem can be solved by using non-capturing parentheses:

QRegExp rx("(\d+)(?:\s*)(cm|inch(?:es)?)"); int pos = rx.indexIn("Length: 36 inches"); QStringList list = rx.capturedTexts(); // list is now ("36 inches", "36", "inches")

Note that if you want to iterate over the list, you should iterate over a copy, e.g.

QStringList list = rx.capturedTexts(); QStringList::iterator it = list.begin(); while (it != list.end()) { myProcessing(*it); ++it; }

Some regexps can match an indeterminate number of times. For example if the input string is "Offsets: 12 14 99 231 7" and the regexp, rx, is (\d+)+, we would hope to get a list of all the numbers matched. However, after calling rx.indexIn(str), capturedTexts() will return the list ("12", "12"), i.e. the entire match was "12" and the first subexpression matched was "12". The correct approach is to use cap() in a loop.

The order of elements in the string list is as follows. The first element is the entire matching string. Each subsequent element corresponds to the next capturing open left parentheses. Thus capturedTexts()[1] is the text of the first capturing parentheses, capturedTexts()[2] is the text of the second and so on (corresponding to $1, $2, etc., in some other regexp languages).

See also cap() and pos().

pub unsafe fn captured_texts_mut(&mut self) -> CppBox<QStringList>[src]

Returns a list of the captured text strings.

Calls C++ function: QStringList QRegExp::capturedTexts().

C++ documentation:

Returns a list of the captured text strings.

The first string in the list is the entire matched string. Each subsequent list element contains a string that matched a (capturing) subexpression of the regexp.

For example:

QRegExp rx("(\d+)(\s*)(cm|inch(es)?)"); int pos = rx.indexIn("Length: 36 inches"); QStringList list = rx.capturedTexts(); // list is now ("36 inches", "36", " ", "inches", "es")

The above example also captures elements that may be present but which we have no interest in. This problem can be solved by using non-capturing parentheses:

QRegExp rx("(\d+)(?:\s*)(cm|inch(?:es)?)"); int pos = rx.indexIn("Length: 36 inches"); QStringList list = rx.capturedTexts(); // list is now ("36 inches", "36", "inches")

Note that if you want to iterate over the list, you should iterate over a copy, e.g.

QStringList list = rx.capturedTexts(); QStringList::iterator it = list.begin(); while (it != list.end()) { myProcessing(*it); ++it; }

Some regexps can match an indeterminate number of times. For example if the input string is "Offsets: 12 14 99 231 7" and the regexp, rx, is (\d+)+, we would hope to get a list of all the numbers matched. However, after calling rx.indexIn(str), capturedTexts() will return the list ("12", "12"), i.e. the entire match was "12" and the first subexpression matched was "12". The correct approach is to use cap() in a loop.

The order of elements in the string list is as follows. The first element is the entire matching string. Each subsequent element corresponds to the next capturing open left parentheses. Thus capturedTexts()[1] is the text of the first capturing parentheses, capturedTexts()[2] is the text of the second and so on (corresponding to $1, $2, etc., in some other regexp languages).

See also cap() and pos().

pub unsafe fn case_sensitivity(&self) -> CaseSensitivity[src]

Returns Qt::CaseSensitive if the regexp is matched case sensitively; otherwise returns Qt::CaseInsensitive.

Calls C++ function: Qt::CaseSensitivity QRegExp::caseSensitivity() const.

C++ documentation:

Returns Qt::CaseSensitive if the regexp is matched case sensitively; otherwise returns Qt::CaseInsensitive.

See also setCaseSensitivity(), patternSyntax(), pattern(), and isMinimal().

pub unsafe fn copy_from(
    &mut self,
    rx: impl CastInto<Ref<QRegExp>>
) -> MutRef<QRegExp>
[src]

Copies the regular expression rx and returns a reference to the copy. The case sensitivity, wildcard, and minimal matching options are also copied.

Calls C++ function: QRegExp& QRegExp::operator=(const QRegExp& rx).

C++ documentation:

Copies the regular expression rx and returns a reference to the copy. The case sensitivity, wildcard, and minimal matching options are also copied.

pub unsafe fn error_string(&self) -> CppBox<QString>[src]

Returns a text string that explains why a regexp pattern is invalid the case being; otherwise returns "no error occurred".

Calls C++ function: QString QRegExp::errorString() const.

C++ documentation:

Returns a text string that explains why a regexp pattern is invalid the case being; otherwise returns "no error occurred".

See also isValid().

pub unsafe fn error_string_mut(&mut self) -> CppBox<QString>[src]

Returns a text string that explains why a regexp pattern is invalid the case being; otherwise returns "no error occurred".

Calls C++ function: QString QRegExp::errorString().

C++ documentation:

Returns a text string that explains why a regexp pattern is invalid the case being; otherwise returns "no error occurred".

See also isValid().

pub unsafe fn escape(str: impl CastInto<Ref<QString>>) -> CppBox<QString>[src]

Returns the string str with every regexp special character escaped with a backslash. The special characters are $, (,), *, +, ., ?, [, ,], ^, {, | and }.

Calls C++ function: static QString QRegExp::escape(const QString& str).

C++ documentation:

Returns the string str with every regexp special character escaped with a backslash. The special characters are $, (,), *, +, ., ?, [, ,], ^, {, | and }.

Example:

s1 = QRegExp::escape("bingo"); // s1 == "bingo" s2 = QRegExp::escape("f(x)"); // s2 == "f\(x\)"

This function is useful to construct regexp patterns dynamically:

QRegExp rx("(" + QRegExp::escape(name) + "|" + QRegExp::escape(alias) + ")");

See also setPatternSyntax().

pub unsafe fn exact_match(&self, str: impl CastInto<Ref<QString>>) -> bool[src]

Returns true if str is matched exactly by this regular expression; otherwise returns false. You can determine how much of the string was matched by calling matchedLength().

Calls C++ function: bool QRegExp::exactMatch(const QString& str) const.

C++ documentation:

Returns true if str is matched exactly by this regular expression; otherwise returns false. You can determine how much of the string was matched by calling matchedLength().

For a given regexp string R, exactMatch("R") is the equivalent of indexIn("^R$") since exactMatch() effectively encloses the regexp in the start of string and end of string anchors, except that it sets matchedLength() differently.

For example, if the regular expression is blue, then exactMatch() returns true only for input blue. For inputs bluebell, blutak and lightblue, exactMatch() returns false and matchedLength() will return 4, 3 and 0 respectively.

Although const, this function sets matchedLength(), capturedTexts(), and pos().

See also indexIn() and lastIndexIn().

pub unsafe fn index_in_3a(
    &self,
    str: impl CastInto<Ref<QString>>,
    offset: c_int,
    caret_mode: CaretMode
) -> c_int
[src]

Attempts to find a match in str from position offset (0 by default). If offset is -1, the search starts at the last character; if -2, at the next to last character; etc.

Calls C++ function: int QRegExp::indexIn(const QString& str, int offset = …, QRegExp::CaretMode caretMode = …) const.

C++ documentation:

Attempts to find a match in str from position offset (0 by default). If offset is -1, the search starts at the last character; if -2, at the next to last character; etc.

Returns the position of the first match, or -1 if there was no match.

The caretMode parameter can be used to instruct whether ^ should match at index 0 or at offset.

You might prefer to use QString::indexOf(), QString::contains(), or even QStringList::filter(). To replace matches use QString::replace().

Example:

QString str = "offsets: 1.23 .50 71.00 6.00"; QRegExp rx("\d*\.\d+"); // primitive floating point matching int count = 0; int pos = 0; while ((pos = rx.indexIn(str, pos)) != -1) { ++count; pos += rx.matchedLength(); } // pos will be 9, 14, 18 and finally 24; count will end up as 4

Although const, this function sets matchedLength(), capturedTexts() and pos().

If the QRegExp is a wildcard expression (see setPatternSyntax()) and want to test a string against the whole wildcard expression, use exactMatch() instead of this function.

See also lastIndexIn() and exactMatch().

pub unsafe fn index_in_2a(
    &self,
    str: impl CastInto<Ref<QString>>,
    offset: c_int
) -> c_int
[src]

Attempts to find a match in str from position offset (0 by default). If offset is -1, the search starts at the last character; if -2, at the next to last character; etc.

Calls C++ function: int QRegExp::indexIn(const QString& str, int offset = …) const.

C++ documentation:

Attempts to find a match in str from position offset (0 by default). If offset is -1, the search starts at the last character; if -2, at the next to last character; etc.

Returns the position of the first match, or -1 if there was no match.

The caretMode parameter can be used to instruct whether ^ should match at index 0 or at offset.

You might prefer to use QString::indexOf(), QString::contains(), or even QStringList::filter(). To replace matches use QString::replace().

Example:

QString str = "offsets: 1.23 .50 71.00 6.00"; QRegExp rx("\d*\.\d+"); // primitive floating point matching int count = 0; int pos = 0; while ((pos = rx.indexIn(str, pos)) != -1) { ++count; pos += rx.matchedLength(); } // pos will be 9, 14, 18 and finally 24; count will end up as 4

Although const, this function sets matchedLength(), capturedTexts() and pos().

If the QRegExp is a wildcard expression (see setPatternSyntax()) and want to test a string against the whole wildcard expression, use exactMatch() instead of this function.

See also lastIndexIn() and exactMatch().

pub unsafe fn index_in_1a(&self, str: impl CastInto<Ref<QString>>) -> c_int[src]

Attempts to find a match in str from position offset (0 by default). If offset is -1, the search starts at the last character; if -2, at the next to last character; etc.

Calls C++ function: int QRegExp::indexIn(const QString& str) const.

C++ documentation:

Attempts to find a match in str from position offset (0 by default). If offset is -1, the search starts at the last character; if -2, at the next to last character; etc.

Returns the position of the first match, or -1 if there was no match.

The caretMode parameter can be used to instruct whether ^ should match at index 0 or at offset.

You might prefer to use QString::indexOf(), QString::contains(), or even QStringList::filter(). To replace matches use QString::replace().

Example:

QString str = "offsets: 1.23 .50 71.00 6.00"; QRegExp rx("\d*\.\d+"); // primitive floating point matching int count = 0; int pos = 0; while ((pos = rx.indexIn(str, pos)) != -1) { ++count; pos += rx.matchedLength(); } // pos will be 9, 14, 18 and finally 24; count will end up as 4

Although const, this function sets matchedLength(), capturedTexts() and pos().

If the QRegExp is a wildcard expression (see setPatternSyntax()) and want to test a string against the whole wildcard expression, use exactMatch() instead of this function.

See also lastIndexIn() and exactMatch().

pub unsafe fn is_empty(&self) -> bool[src]

Returns true if the pattern string is empty; otherwise returns false.

Calls C++ function: bool QRegExp::isEmpty() const.

C++ documentation:

Returns true if the pattern string is empty; otherwise returns false.

If you call exactMatch() with an empty pattern on an empty string it will return true; otherwise it returns false since it operates over the whole string. If you call indexIn() with an empty pattern on any string it will return the start offset (0 by default) because the empty pattern matches the 'emptiness' at the start of the string. In this case the length of the match returned by matchedLength() will be 0.

See QString::isEmpty().

pub unsafe fn is_minimal(&self) -> bool[src]

Returns true if minimal (non-greedy) matching is enabled; otherwise returns false.

Calls C++ function: bool QRegExp::isMinimal() const.

C++ documentation:

Returns true if minimal (non-greedy) matching is enabled; otherwise returns false.

See also caseSensitivity() and setMinimal().

pub unsafe fn is_valid(&self) -> bool[src]

Returns true if the regular expression is valid; otherwise returns false. An invalid regular expression never matches.

Calls C++ function: bool QRegExp::isValid() const.

C++ documentation:

Returns true if the regular expression is valid; otherwise returns false. An invalid regular expression never matches.

The pattern [a-z is an example of an invalid pattern, since it lacks a closing square bracket.

Note that the validity of a regexp may also depend on the setting of the wildcard flag, for example *.html is a valid wildcard regexp but an invalid full regexp.

See also errorString().

pub unsafe fn last_index_in_3a(
    &self,
    str: impl CastInto<Ref<QString>>,
    offset: c_int,
    caret_mode: CaretMode
) -> c_int
[src]

Attempts to find a match backwards in str from position offset. If offset is -1 (the default), the search starts at the last character; if -2, at the next to last character; etc.

Calls C++ function: int QRegExp::lastIndexIn(const QString& str, int offset = …, QRegExp::CaretMode caretMode = …) const.

C++ documentation:

Attempts to find a match backwards in str from position offset. If offset is -1 (the default), the search starts at the last character; if -2, at the next to last character; etc.

Returns the position of the first match, or -1 if there was no match.

The caretMode parameter can be used to instruct whether ^ should match at index 0 or at offset.

Although const, this function sets matchedLength(), capturedTexts() and pos().

Warning: Searching backwards is much slower than searching forwards.

See also indexIn() and exactMatch().

pub unsafe fn last_index_in_2a(
    &self,
    str: impl CastInto<Ref<QString>>,
    offset: c_int
) -> c_int
[src]

Attempts to find a match backwards in str from position offset. If offset is -1 (the default), the search starts at the last character; if -2, at the next to last character; etc.

Calls C++ function: int QRegExp::lastIndexIn(const QString& str, int offset = …) const.

C++ documentation:

Attempts to find a match backwards in str from position offset. If offset is -1 (the default), the search starts at the last character; if -2, at the next to last character; etc.

Returns the position of the first match, or -1 if there was no match.

The caretMode parameter can be used to instruct whether ^ should match at index 0 or at offset.

Although const, this function sets matchedLength(), capturedTexts() and pos().

Warning: Searching backwards is much slower than searching forwards.

See also indexIn() and exactMatch().

pub unsafe fn last_index_in_1a(&self, str: impl CastInto<Ref<QString>>) -> c_int[src]

Attempts to find a match backwards in str from position offset. If offset is -1 (the default), the search starts at the last character; if -2, at the next to last character; etc.

Calls C++ function: int QRegExp::lastIndexIn(const QString& str) const.

C++ documentation:

Attempts to find a match backwards in str from position offset. If offset is -1 (the default), the search starts at the last character; if -2, at the next to last character; etc.

Returns the position of the first match, or -1 if there was no match.

The caretMode parameter can be used to instruct whether ^ should match at index 0 or at offset.

Although const, this function sets matchedLength(), capturedTexts() and pos().

Warning: Searching backwards is much slower than searching forwards.

See also indexIn() and exactMatch().

pub unsafe fn matched_length(&self) -> c_int[src]

Returns the length of the last matched string, or -1 if there was no match.

Calls C++ function: int QRegExp::matchedLength() const.

C++ documentation:

Returns the length of the last matched string, or -1 if there was no match.

See also exactMatch(), indexIn(), and lastIndexIn().

pub unsafe fn new_0a() -> CppBox<QRegExp>[src]

Constructs an empty regexp.

Calls C++ function: [constructor] void QRegExp::QRegExp().

C++ documentation:

Constructs an empty regexp.

See also isValid() and errorString().

pub unsafe fn new_3a(
    pattern: impl CastInto<Ref<QString>>,
    cs: CaseSensitivity,
    syntax: PatternSyntax
) -> CppBox<QRegExp>
[src]

Constructs a regular expression object for the given pattern string. The pattern must be given using wildcard notation if syntax is Wildcard; the default is RegExp. The pattern is case sensitive, unless cs is Qt::CaseInsensitive. Matching is greedy (maximal), but can be changed by calling setMinimal().

Calls C++ function: [constructor] void QRegExp::QRegExp(const QString& pattern, Qt::CaseSensitivity cs = …, QRegExp::PatternSyntax syntax = …).

C++ documentation:

Constructs a regular expression object for the given pattern string. The pattern must be given using wildcard notation if syntax is Wildcard; the default is RegExp. The pattern is case sensitive, unless cs is Qt::CaseInsensitive. Matching is greedy (maximal), but can be changed by calling setMinimal().

See also setPattern(), setCaseSensitivity(), and setPatternSyntax().

pub unsafe fn new_2a(
    pattern: impl CastInto<Ref<QString>>,
    cs: CaseSensitivity
) -> CppBox<QRegExp>
[src]

Constructs a regular expression object for the given pattern string. The pattern must be given using wildcard notation if syntax is Wildcard; the default is RegExp. The pattern is case sensitive, unless cs is Qt::CaseInsensitive. Matching is greedy (maximal), but can be changed by calling setMinimal().

Calls C++ function: [constructor] void QRegExp::QRegExp(const QString& pattern, Qt::CaseSensitivity cs = …).

C++ documentation:

Constructs a regular expression object for the given pattern string. The pattern must be given using wildcard notation if syntax is Wildcard; the default is RegExp. The pattern is case sensitive, unless cs is Qt::CaseInsensitive. Matching is greedy (maximal), but can be changed by calling setMinimal().

See also setPattern(), setCaseSensitivity(), and setPatternSyntax().

pub unsafe fn new_1a(pattern: impl CastInto<Ref<QString>>) -> CppBox<QRegExp>[src]

Constructs a regular expression object for the given pattern string. The pattern must be given using wildcard notation if syntax is Wildcard; the default is RegExp. The pattern is case sensitive, unless cs is Qt::CaseInsensitive. Matching is greedy (maximal), but can be changed by calling setMinimal().

Calls C++ function: [constructor] void QRegExp::QRegExp(const QString& pattern).

C++ documentation:

Constructs a regular expression object for the given pattern string. The pattern must be given using wildcard notation if syntax is Wildcard; the default is RegExp. The pattern is case sensitive, unless cs is Qt::CaseInsensitive. Matching is greedy (maximal), but can be changed by calling setMinimal().

See also setPattern(), setCaseSensitivity(), and setPatternSyntax().

pub unsafe fn new_copy(rx: impl CastInto<Ref<QRegExp>>) -> CppBox<QRegExp>[src]

Constructs a regular expression as a copy of rx.

Calls C++ function: [constructor] void QRegExp::QRegExp(const QRegExp& rx).

C++ documentation:

Constructs a regular expression as a copy of rx.

See also operator=().

pub unsafe fn pattern(&self) -> CppBox<QString>[src]

Returns the pattern string of the regular expression. The pattern has either regular expression syntax or wildcard syntax, depending on patternSyntax().

Calls C++ function: QString QRegExp::pattern() const.

C++ documentation:

Returns the pattern string of the regular expression. The pattern has either regular expression syntax or wildcard syntax, depending on patternSyntax().

See also setPattern(), patternSyntax(), and caseSensitivity().

pub unsafe fn pattern_syntax(&self) -> PatternSyntax[src]

Returns the syntax used by the regular expression. The default is QRegExp::RegExp.

Calls C++ function: QRegExp::PatternSyntax QRegExp::patternSyntax() const.

C++ documentation:

Returns the syntax used by the regular expression. The default is QRegExp::RegExp.

See also setPatternSyntax(), pattern(), and caseSensitivity().

pub unsafe fn pos_1a(&self, nth: c_int) -> c_int[src]

Returns the position of the nth captured text in the searched string. If nth is 0 (the default), pos() returns the position of the whole match.

Calls C++ function: int QRegExp::pos(int nth = …) const.

C++ documentation:

Returns the position of the nth captured text in the searched string. If nth is 0 (the default), pos() returns the position of the whole match.

Example:

QRegExp rx("/([a-z]+)/([a-z]+)"); rx.indexIn("Output /dev/null"); // returns 7 (position of /dev/null) rx.pos(0); // returns 7 (position of /dev/null) rx.pos(1); // returns 8 (position of dev) rx.pos(2); // returns 12 (position of null)

For zero-length matches, pos() always returns -1. (For example, if cap(4) would return an empty string, pos(4) returns -1.) This is a feature of the implementation.

See also cap() and capturedTexts().

pub unsafe fn pos_1a_mut(&mut self, nth: c_int) -> c_int[src]

Returns the position of the nth captured text in the searched string. If nth is 0 (the default), pos() returns the position of the whole match.

Calls C++ function: int QRegExp::pos(int nth = …).

C++ documentation:

Returns the position of the nth captured text in the searched string. If nth is 0 (the default), pos() returns the position of the whole match.

Example:

QRegExp rx("/([a-z]+)/([a-z]+)"); rx.indexIn("Output /dev/null"); // returns 7 (position of /dev/null) rx.pos(0); // returns 7 (position of /dev/null) rx.pos(1); // returns 8 (position of dev) rx.pos(2); // returns 12 (position of null)

For zero-length matches, pos() always returns -1. (For example, if cap(4) would return an empty string, pos(4) returns -1.) This is a feature of the implementation.

See also cap() and capturedTexts().

pub unsafe fn pos_0a(&self) -> c_int[src]

Returns the position of the nth captured text in the searched string. If nth is 0 (the default), pos() returns the position of the whole match.

Calls C++ function: int QRegExp::pos() const.

C++ documentation:

Returns the position of the nth captured text in the searched string. If nth is 0 (the default), pos() returns the position of the whole match.

Example:

QRegExp rx("/([a-z]+)/([a-z]+)"); rx.indexIn("Output /dev/null"); // returns 7 (position of /dev/null) rx.pos(0); // returns 7 (position of /dev/null) rx.pos(1); // returns 8 (position of dev) rx.pos(2); // returns 12 (position of null)

For zero-length matches, pos() always returns -1. (For example, if cap(4) would return an empty string, pos(4) returns -1.) This is a feature of the implementation.

See also cap() and capturedTexts().

pub unsafe fn pos_0a_mut(&mut self) -> c_int[src]

Returns the position of the nth captured text in the searched string. If nth is 0 (the default), pos() returns the position of the whole match.

Calls C++ function: int QRegExp::pos().

C++ documentation:

Returns the position of the nth captured text in the searched string. If nth is 0 (the default), pos() returns the position of the whole match.

Example:

QRegExp rx("/([a-z]+)/([a-z]+)"); rx.indexIn("Output /dev/null"); // returns 7 (position of /dev/null) rx.pos(0); // returns 7 (position of /dev/null) rx.pos(1); // returns 8 (position of dev) rx.pos(2); // returns 12 (position of null)

For zero-length matches, pos() always returns -1. (For example, if cap(4) would return an empty string, pos(4) returns -1.) This is a feature of the implementation.

See also cap() and capturedTexts().

pub unsafe fn set_case_sensitivity(&mut self, cs: CaseSensitivity)[src]

Sets case sensitive matching to cs.

Calls C++ function: void QRegExp::setCaseSensitivity(Qt::CaseSensitivity cs).

C++ documentation:

Sets case sensitive matching to cs.

If cs is Qt::CaseSensitive, \.txt$ matches readme.txt but not README.TXT.

See also caseSensitivity(), setPatternSyntax(), setPattern(), and setMinimal().

pub unsafe fn set_minimal(&mut self, minimal: bool)[src]

Enables or disables minimal matching. If minimal is false, matching is greedy (maximal) which is the default.

Calls C++ function: void QRegExp::setMinimal(bool minimal).

C++ documentation:

Enables or disables minimal matching. If minimal is false, matching is greedy (maximal) which is the default.

For example, suppose we have the input string "We must be <b>bold</b>, very <b>bold</b>!" and the pattern <b>.*</b>. With the default greedy (maximal) matching, the match is "We must be <b>bold</b>, very <b>bold</b>!". But with minimal (non-greedy) matching, the first match is: "We must be <b>bold</b>, very <b>bold</b>!" and the second match is "We must be <b>bold</b>, very <b>bold</b>!". In practice we might use the pattern <b>[^<]*</b> instead, although this will still fail for nested tags.

See also isMinimal() and setCaseSensitivity().

pub unsafe fn set_pattern(&mut self, pattern: impl CastInto<Ref<QString>>)[src]

Sets the pattern string to pattern. The case sensitivity, wildcard, and minimal matching options are not changed.

Calls C++ function: void QRegExp::setPattern(const QString& pattern).

C++ documentation:

Sets the pattern string to pattern. The case sensitivity, wildcard, and minimal matching options are not changed.

See also pattern(), setPatternSyntax(), and setCaseSensitivity().

pub unsafe fn set_pattern_syntax(&mut self, syntax: PatternSyntax)[src]

Sets the syntax mode for the regular expression. The default is QRegExp::RegExp.

Calls C++ function: void QRegExp::setPatternSyntax(QRegExp::PatternSyntax syntax).

C++ documentation:

Sets the syntax mode for the regular expression. The default is QRegExp::RegExp.

Setting syntax to QRegExp::Wildcard enables simple shell-like QRegExp wildcard matching. For example, r*.txt matches the string readme.txt in wildcard mode, but does not match readme.

Setting syntax to QRegExp::FixedString means that the pattern is interpreted as a plain string. Special characters (e.g., backslash) don't need to be escaped then.

See also patternSyntax(), setPattern(), setCaseSensitivity(), and escape().

pub unsafe fn swap(&mut self, other: impl CastInto<MutRef<QRegExp>>)[src]

Swaps regular expression other with this regular expression. This operation is very fast and never fails.

Calls C++ function: void QRegExp::swap(QRegExp& other).

C++ documentation:

Swaps regular expression other with this regular expression. This operation is very fast and never fails.

This function was introduced in Qt 4.8.

Trait Implementations

impl PartialEq<Ref<QRegExp>> for QRegExp[src]

fn eq(&self, rx: &Ref<QRegExp>) -> bool[src]

Returns true if this regular expression is equal to rx; otherwise returns false.

Calls C++ function: bool QRegExp::operator==(const QRegExp& rx) const.

C++ documentation:

Returns true if this regular expression is equal to rx; otherwise returns false.

Two QRegExp objects are equal if they have the same pattern strings and the same settings for case sensitivity, wildcard and minimal matching.

impl CppDeletable for QRegExp[src]

unsafe fn delete(&mut self)[src]

Destroys the regular expression and cleans up its internal data.

Calls C++ function: [destructor] void QRegExp::~QRegExp().

C++ documentation:

Destroys the regular expression and cleans up its internal data.

Auto Trait Implementations

impl Send for QRegExp

impl Sync for QRegExp

impl Unpin for QRegExp

impl UnwindSafe for QRegExp

impl RefUnwindSafe for QRegExp

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> StaticUpcast<T> for T[src]

impl<T, U> CastInto<U> for T where
    U: CastFrom<T>, 
[src]