Can I check for frames that don’t contain digits?

Regex – Regular Expression

A RegEx (Regular Expression) is a pattern matching method often used in text searches and data processing. Cradle supports Regex matches in a number of query elements, so it is possible to perform complex searches on your data. This article gives an example of the use of Regexes in frames.

Example:

The mocked up example describes just one of the ways a user could search the text frames of their items achieve particular results.

IdentityNameGroupText
bed1Single BedroomCustomer roomsSingle person room of basic standard – en-suite shower
bed2Double BedroomCustomer roomsA 2 person occupancy room, shared bed en-suite shower
bed3Twin BedroomCustomer roomsA 2 person occupancy room, single beds, en-suite shower
bed4Luxury BedroomCustomer roomsA 1 or 2 person occupancy room double bed, en-suite with bath and shower.
bed5Night Staff RestStaff rooms1 person
store1Cleaning storeroom

The data in the table above used a Cradle Note called Bedroom and was produced by running the automatic query “BEDROOM – All”. Then the resulting  table was published to HTML. There were no regexes in frames applied to the initial query.

Queries with Regexes in Frames

    • Simply entering “TEXT” as the Name of the frame to search and running the query will bring back bed1-bed5. The item store1 has no content to compare so can’t match.
    • Entering bath in the Regexes field and re-running will return bed4  this is the most basic case the text typed in is simply found as a direct match.
    • If you want to find the incomplete items and find those with a blank frame using the Cradle extension of <null> in the Regexes field will return store1 as this has nothing in the frame.
    • If we want the query to find those that have not used a digit  in the description (This may be important if the output is parsed by some other program) it is possible to use a regex character class [[:digit:]] . This will find all the elements containing a digit ≍ [0-9]. However, if we want the elements that don’t contain numbers, we can use the second Cradle extension of ! to negate the result, hence ![[:digit]] will return bed1 as it used the word ‘single’ rather than a digit for its occupancy value.
    • Cradle also allows comma separated logical combinations of regexes in frames. Using the Venn diagram symbol you can select whether these are AND or OR combinations. Switching to AND and then using the regex [[:digit:]],![[:alpha]] would bring back items where the frame contained digits and no alphabetic characters.
screenshots of results using regexes in frames in Cradle
Regexes in Frames

Exploring Regexes

A simple way of testing whether your regex will give you the results you want is to use a test program regex101.com/ is a good example. This allows you to quickly tweak your statement, and run it against various test data.
Cradle uses the PCRE ‘flavour’ internally.
The Cradle help system has further information on regexes