B4P supports wildcards which enables for more effective search and comparison functions as they enable pattern matching with concepts such as
Wildcards are used, amongst others, in following functionalities:
Unless specified otherwise (like in searching files), wildcard symbols in strings will only work if specified as softquoted strings (e.g. text inside single quotation marks).
Symbol | Meaning | Example | Explanation |
---|---|---|---|
Plaholder for any number of characters (incl. 0) | A* *s *-* A*E | Begins with 'A' Ends with 's' Contains '-' Begins with 'A' and ends with 'E' | |
~ | Placeholder for any number of letters (incl. 0) Foreign (non-ANSI) characters are accepted here, too. | ~ Street | Expecting a name for the street (letters only) |
& | Placeholder for any number of numeric digits 0..9 | & kg | Expects a number of any size before ' kg' |
? | Placeholder for exactly 1 character | ??? A? | Contains 3 characters of choice A follwed by 1 character of choice |
# | Placeholder for exactly 1 numeric digit 0..9 | ###-##-#### | Expect a social security number (U.S. number format) |
^ | Placeholder for exactly 1 alphanumeric character Foreign (non-ANSI) characters are accepted here, too. | ^^^ | Expect 3 letters |
, | Defines additional pattern to compare | A*,B*,C* | May begin with A, B or C. |
For searching files using directory and file functions, the wildcards are limited to * and ?.
table initialize ( demo wildcards,
{ { String, '*', '~', 'B*', '&', 'Zip*#####', '??t', '*t', 'A*,B*,C*','*##','*i*','*i*1*' },
Hello,
'',
12,
123,
1234,
12345,
Zip 12010,
Zip__12010,
Zip 1201,
Cat,
Bat,
Bit,
halt } );
table configure( demo wildcards, read numerals, no ); // Read numbers from tables as strings
table process( demo wildcards,
for (c[] = 1, c[] < table row width( demo wildcards, 0 ), c[]++ )
{
[c[]] = [0] = soft( [c[], 0 ] ); // Compare and write the result
// Current Column Compared with corresponding header name above
// column zero
} );
table list( demo wildcards );
0 : String | * | ~ | B* | & | Zip*##### | ??t | *t | A*,B*,C* | *## | *i* | *i*1*
1 : Hello | true | true | false | false | false | false | false | false | false | false | false
2 : | true | true | false | true | false | false | false | false | false | false | false
3 : 12 | true | false | false | true | false | false | false | false | true | false | false
4 : 123 | true | false | false | true | false | false | false | false | true | false | false
5 : 1234 | true | false | false | true | false | false | false | false | true | false | false
6 : 12345 | true | false | false | true | false | false | false | false | true | false | false
7 : Zip 12010 | true | false | false | false | true | false | false | false | true | true | true
8 : Zip__12010 | true | false | false | false | true | false | false | false | true | true | true
9 : Zip 1201 | true | false | false | false | false | false | false | false | true | true | true
10 : Cat | true | true | false | false | false | true | true | true | false | false | false
11 : Bat | true | true | true | false | false | true | true | true | false | false | false
12 : Bit | true | true | true | false | false | true | true | true | false | true | false
13 : halt | true | true | false | false | false | false | true | false | false | false | false