https://help.tallysolutions.com/docs/td9rel54/td9/search_and_replace/writing_regular_expressions.htm

Writing Regular Expressions

A regular expression is a precise pattern that provides a very efficient way to specify and recognize strings of text. A combination of various characters along with the text to be searched for generates a regular expression.

Tally.Developer 9 uses regular expression to search for text based on specified patterns. These patterns are a combination of special characters and the text that needs to be searched for.

Some examples are given in the table below:

Character

Description

Example

^

Used to match the start of a line

^Local

This expression will search for all lines that start with Local

$

Used to match the end of a line

$Tally

This expression will search for all lines that end with Tally

.

Used to match or replace a Single Character

F.rm

This expression will search for all terms which start with F, have one character in the middle and end with rm

*

Searches for zero or more occurrences of the preceding character

Lo*cal

This expression will search for Lcal, Local, Loocal, Looocal...

+

Searches for one or more occurrences of the preceding character

Lo+cal

This expression will search for all terms Local, Loocal, Looocal.....

\x

Used to search for a character which otherwise may have another meaning

\

This expression will search for locations where '[' is present.

\<

Used to match the start of a word

\<Ad

This expression will search for all terms that begin with Ad

\>

Used to match the end of a word

\>ed

This expression is used for all terms that end with ed

\(

Used to denote the start of a region for tagging a match

\)

Used to denote the end of a region for tagging a match

[.....]

Denotes a set of possible character matches

[A-z]

It will search for terms with characters between a to z

[^...]

Used to indicate complement of a set of characters

[^A-d]

lt will not search for terms with characters between a to d

\d

Used to match a digit

Tally\(\d+\)

It will search for terms with a combination of text and numbers like Tally1, Tally512

\s

Used to match a white space character

Tally\s

It will search for terms with Tally and a line feed character after it like space or tab

Combination of Characters

To make a search more refined, we use a combination of characters. Any of the characters given above can be used in conjunction with each other to get a thoroughly enhanced output. Given below are a few examples to explain how this can be done.

Regular Expression

Result

^Tally\([abc]\)

This will search for terms which start at the beginning of the line and consist of Tallya, Tallyb or Tallyc.

Tal*y\(\d+\)

This will search for terms which have zero or more occurrences of l between a and y and any digits after the text.

^.$

This will search for lines containing only a single character.

^Pa?

This will search for any term which has a P OR Pa at the beginning of the line.

From the above examples we can see that regular expression is the term used to describe a codified method of searching which enables fast and responsive searches.