Get advice from the PIQNIC team

Regular Expressions and Email Variables in Piqnic

This section describes variables used in the creation of email templates as well as syntax of regular expressions used in the definition of Searches and Save Profiles

Syntax of email variables implemented

The following variables/placeholders can be used in the email templates. 

PlaceholdersAliasRemarks
${senderName}User nameThis variable replaces the name of the document sender at run time. 
${organisationName}Organization nameAt run time adds ‘organization name’ to the email.
${message}MessageThis variable puts the content written by the user at the time of document email. This also adds the task chat message’ at run time in wall message notification. 
${UserFirstName}User first nameAt run time adds ‘first name’ of the receiver.
${ActivityInitiator}Initiator nameAt run time adds ‘first name’ of the activity initiator in the email.
${TaskName}Task nameTo get task name and url for redirection in task email, it needs to be retrieved from object. So use following:  <#if TaskName.url == ‘null’>${TaskName.name}<#else>${TaskName.name} where ${TaskName.name} is hyperlinked with ${TaskName.url}. 
${period}Expiring inAt run time adds ‘period’ of the task expiration in the email which can be 1day, 4hours or 1hour for task expiry emails.
${FromDate}DateAt run time adds delegation start ‘date’ in the email. 
${EndDate}DateAt run time adds delegation End ‘date’ in the email. 
${TaskStatus}Task statusThis variable shows status of the task at run time in the email notification. 
${DocumentTitle}Document titleAt run time adds ‘title of the document’ in the email.
${DocumentFileTitle}File titleAt run time adds ‘title of the file’ in the email.
${DocumentVersion} Document versionAt run time adds ‘Document version’ of the file in the email.
${decision}Task decisionAt run time adds decision taken by the participant.
${task}Task or project name${task} is a list object that contains task or project name in case of 2IC notification.
${ObjectLink}URLAt run time adds ‘URL’ in the email such as:
·   download file link for log
·   Reset password link
·   Login link
·   Sign Up lin

Regular Expression implementation in Piqnic

A regular expression is a sequence of characters that define a search pattern. Usually this pattern is used by string searching algorithms for “find” or “find and replace”.

The regex is being utilized in following areas of the system:

·      Save profile prompts

·      Document search query

·      Transformation field values in batch definition

Save profile prompts

The save profile allows to define regex for the input prompts. At run time the input filed validates the input according to the regex. 

Searches

Search definitions allow setting up the rules for RegEx pattern matching to validate user input. For instance, the regex will be as follows for the search document title containing ‘piqnic’ keyword.  

QuerydocumentTitle should contain ‘piqnic’
regex^((?!piqnic).)*$

Transformation

The transformation can be defined in batch upload definition to find a pattern and replace it with something else. 

For example, following query finds ‘piqnic’ keyword in the metadata field and replaces it with ‘ecom’: 

Queryreplace all places of “piqnic” pattern to “niqpic”
TRANSFORMATIONSTRANSFORMATION VALUE
piqnicniqpic

At run time, ‘piqnic’ is replaced with ‘niqpic’. 

Implementation

Regular expressions are used to perform pattern-matching and “search-and-replace” functions on text.

Syntax

/pattern/modifiers;

Example

var patt = /w3schools/i

Example explained:

/w3schools/i  is a regular expression.

w3schools is a pattern (to be used in a search).

i  is a modifier (modifies the search to be case-insensitive).

Modifiers

Modifiers are used to perform case-insensitive and global searches:

Modifier          Description

g          Perform a global match (find all matches rather than stopping after the first match)

i           Perform case-insensitive matching

m         Perform multiline matching

Brackets

Brackets are used to find a range of characters:

Expression       Description

[abc]    Find any character between the brackets

[^abc]  Find any character NOT between the brackets

[0-9]    Find any character between the brackets (any digit)

[^0-9]  Find any character NOT between the brackets (any non-digit)

(x|y)    Find any of the alternatives specified

Metacharacters

Metacharacters are characters with a special meaning:

Metacharacter            Description

.           Find a single character, except newline or line terminator

\w        Find a word character

\W       Find a non-word character

\d        Find a digit

\D        Find a non-digit character

\s         Find a whitespace character

\S         Find a non-whitespace character

\b        Find a match at the beginning/end of a word, beginning like this: \bHI, end like this: HI\b

\B        Find a match, but not at the beginning/end of a word

\0        Find a NUL character

\n        Find a new line character

\f         Find a form feed character

\r         Find a carriage return character

\t         Find a tab character

\v         Find a vertical tab character

\xxx     Find the character specified by an octal number xxx

\xdd     Find the character specified by a hexadecimal number dd

\udddd            Find the Unicode character specified by a hexadecimal number dddd

Quantifiers

Quantifier       Description

n+        Matches any string that contains at least one n

n*        Matches any string that contains zero or more occurrences of n

n?        Matches any string that contains zero or one occurrences of n

n{X}     Matches any string that contains a sequence of X n’s

n{X,Y}  Matches any string that contains a sequence of X to Y n’s

n{X,}    Matches any string that contains a sequence of at least X n’s

n$        Matches any string with n at the end of it

^n        Matches any string with n at the beginning of it

?=n      Matches any string that is followed by a specific string n

?!n       Matches any string that is not followed by a specific string n

References 

Guide
https://www.javamex.com/tutorials/regular expressions/search_replace.shtml
Regular expression testerhttps://www.freeformatter.com/…