Wildcards vs Regex

REQCHECKER™ uses patterns to extract requirements from your documents or other data sources when you use the Syntax mode (read more).

Patterns are expressions that allow REQCHECKER™ to recognize a requirement identifier in the text of your documents. Two different syntaxes exist to achieve this. They use the same general approach based on metacharacters:

  • Wildcards on the one hand are simple and intuitive.
  • Regular expressions on the other hand are more complex but also much more powerful.

The regular expression editor GUI helps you to test your expressions.

Wildcards

The wildcards pattern can use the two following special metacharacters:

  • ? represents a single (exactly one) characters, including space
  • * represents a multiple (zero or more) characters, including space.

This simple and intuitive syntax is generally well known to users who can use it to search for files.

For example:

  • P?rti?l matches Partial, Partiel but not Prtial
  • *tial matches tial, Partial, Martial
  • *.docx matches my document.docx

Regular expressions (regexes)

The option Advanced Reg. Exp. (see Options Menu) changes the syntax used by some tags (see Tag summary).

Regular expressions use much more than 2 metacharacters. Here are some of the most commonly used metacharacters:

  • a matches the a character
  • matches the space character
  • \u00A0 matches the non-breaking space
  • * quantifier, occurs zero or more times.
  • + quantifier, occurs one or more times.
  • ? quantifier, occurs no or one times.
  • {n, m} quantifier, matches at least n and at most m occurrences of preceding expression.
  • . wildcard matches any single character except newline.
  • \w expression matches word characters.
  • \d expression matches digits, equivalent to [0-9].
  • \\ matches the \ character itself
  • [...] set, definition, matches any single character in brackets.
  • [^...] set, matches any single character not in brackets.
  • XZ matches X directly followed by Z.
  • X|Z or, matches X or Z.
  • () grouping, parentheses are used to define the scope and precedence of the operators

For example Monday matches the regex patterns [A-Za-z]+, M[a-x]+y, M.*, (Mon|Tues)day.

Warning

With regular expressions the meaning of ? and * is different from that of wildcards. The equivalent of wildcard ? is the regex . and the equivalent of wildcard * is the regex .*. To remember that this option is enabled, the field is displayed in orange color.

Space and non-breaking space are different characters. Be careful to use [ \u00A0] when required to catch both of them.

Some links to learn advanced regular expression:

  • RegexOne is a free online training.
  • regular expressions 101 allows you to learn how regexs work by identifying the role of each metacharacter through colors and an on-the-fly analysis of several texts.
  • Java Regular Expression is a complete and detailed reference documentation. It corresponds to the syntax used by REQCHECKER™.

Statement extraction with wildcards

Blue cells accept wildcards.

Example 1

<REQ_0010> About box
The software has an about box.
#EndText
#Version 1

<REQ_0020> About Cancel
The about box has a Cancel button.
#Deleted

The syntax is :

  • Advanced Reg. Exp. option : disabled
  • BEGIN STAT = <
  • REQUIREMENT ID = REQ_*
  • END STAT = >
  • END TEXT = #EndText
  • DELETED = #Deleted
  • VERSION = #Version

Example 2

N£  REQ-BASIC-0010  £N
T£ MAX OPERATING CONSUMPTION
Maximum operating consumption is 30W.  £T

Note

Space are not allowed between BEGIN STAT and {{ tags_REQUIREMENT_ID }}, same between {{ tags_REQUIREMENT_ID }} and END STAT. is not useful and is not managed ; it is included in the text of the statement.

The syntax is :

  • Regular expression option : disabled
  • BEGIN STAT =
  • REQUIREMENT ID = REQ-*
  • END STAT = £N
  • END TEXT = £T
  • DELETED = #Deleted
  • VERSION = #Version

Example 3

[CAT-TRA-REQ-192]
Operating System
Upper req:  EXB-TRA-REQ-124
Detail
The software is installable on Windows platform.
End of requirement

The syntax is :

  • Regular expression option : disabled
  • BEGIN STAT= [
  • REQUIREMENT ID = CAT-TRA-REQ-*
  • END STAT = ]
  • END TEXT =
  • DELETED = #Deleted
  • VERSION = #Version
  • CUSTOM_TAG 'Upper req: ' = EXB-TRA-REQ-124
  • CUSTOM_TAG 'Detail' until 'End of requirement' = The software is installable on Windows platform.

Statement extraction with regex

Orange cells accept advanced regular expression (regex).

Example

#R_MYSOFT_REP_L1_003_V00 General - Report - Design - File
Every output report must be available with [Preview] button, as illustrated in the computation function.

#R_MYSOFT_REP_L1_004_V00 General - Report - Design - Page
Each report page must display:
* "Material" [Name]
* "Type" [Type]

The end statement is not used. Then the syntax must limit the variable part to exclude the following text.

The syntax is :

  • Advanced Reg. Exp. option : enabled
  • BEGIN STAT = #
  • REQUIREMENT ID = R_MYSOFT_REP_[LV_0-9]+
  • END STAT =
  • END TEXT =
  • DELETED = #Deleted
  • VERSION = #Version

Coverage extraction with wildcards

Blue cells accept wildcards.

Example

Open the About menu, a dialog box opens with the file name, the copyright and version. <<REQ_0123>> (partial) (v1.4)

The tags are:

  • BEGIN COVER is <<
  • REQUIREMENT ID is REQ_0123
  • END COVER is >>
  • PARTIAL is (partial)
  • BEGIN VERSION is (v
  • END VERSION is )

Coverage extraction with regex

Orange cells accept advanced regular expression (Regex).