Normalization Patterns

  1. Alter Scan Value

This feature enables parsing the original data read when each barcode matching a specified pattern is scanned. It passes only the parsed data as the scan record, whether for recording or validation purposes. This feature is extremely useful if only a portion of the scanned data needs to be submitted, such as the data embedded in driver’s licenses, trade show badges, student and member IDs and asset tags.

If you create a Service and want to alter a scan values, you need to select that option on the Advanced tab and enter scripts in the Alter Value Pattern and Alter Value Replacement fields.

Example Outline

Pattern:

^.{Lp}(.{Lm}).{Ls}$

Replacement:

$1  

The example outline is a pattern and replacement for removing a specified length prefix and suffix and keeping the specified middle.

  • Lp = length of prefix, Lm = length of middle, Ls = length of suffix.

 

Here is an example with real numbers. Let’s say my barcode is of length 10 and I want to remove the first 2 and last 3 characters, keeping the middle 5.

 

Example A

Pattern:

^.{2}(.{5}).{3}$

Replacement:

$1
Pattern breakdown: given value ‘AB34567CDE’, how does it become ‘34567’.

  • ^ = Start of value.
  • .{2} = ‘AB’  –  Match any two characters.
  • (.{5}) = ‘34567’  – Match 5 characters after the first 2. The parenthesis around .{5} stores the match as a group.
  • .{3} = ‘CDE’  –  Match 3 characters after the 5 character group.
  • $ = End of value.

Replacement breakdown

  • $1 = ‘34567’  –  The matched group of 5 characters. It’s identified as $1 because it’s the first expression inside parenthesis. If more values were grouped then they would be identified by the order they appeared from left to right.

The exact same thing as Example A could be achieved where all three sections are grouped but only one is used:

Example B
Pattern:

^(.{2})(.{5})(.{3})$

Replacement:

$2
In Example B you see that we changed the replacement to $2 because the five character match is now the second group and we don’t want the first and third groups.

Example C
Pattern:

^([\s\S]{100})([\s\S]*)$

Replacement:

$1

In Example C the result will be the first 100 characters of the scanned value. You can change {100} to the number of characters you wish to include.

Example D
Pattern:

http://example.com/([\s\S]*)\?token=([\s\S]{14})$

Replacement:

http://example.com/TO_THIS.php?token=$2

In Example D we want to replace part of a URL.

From:   https://example/FROM_THIS.php?token=abcdefghij

To:       https://example/TO_THIS.php?token=abcdefghij

The regex replaces ‘FROM_THIS’ with ‘TO_THIS’ and all else remains the same.

Example E
Pattern:

^([^a-zA-Z][\s\S]*)$

Replacement:

x$1 (where ‘x’ is the prefix to add)

In Example E we want to add a prefix to a barcode value, but only if there’s no alpha character prefix.

From:   1234567890

To:     A1234567890

The regex adds the ‘A’ to actual barcode scanned ‘123567890’.

 

  1. Alter Response Text

This feature enables customization of the information presented to the app user after submitting a scan. When a defined pattern is detected within your original, default response text, the app will instead display custom, formatted text to app user based on the replacement template you create.

This new text is not saved with the scan record, nor does it change your default response text. It will only change what’s displayed to the app user under the defined condition.

For the Alter Response Pattern field, you define a pattern to which the replacement information will apply. In the Alter Response Replacement field, you enter the template of what and how you want the response to be presented to the app user in the app’s response field.

This sophisticated feature is very useful for customizing the presentation of information to the app user. With it you can control how content is displayed, including text, images, type faces and colors using HTML and optionally our Webify tools for real-time data to be presented.

Here are some simple examples to demonstrate the concept:

Example A

1) Simple text replacement

Pattern:

Invalid barcode. Value not in database.(.*?)

Replacement:

This attendee registered on-site. Their information will be available to you when retrieving your leads.

custom response text

Note: To change the color of the response screen and the label from ‘Invalid’ to ‘On-Site Registrant’ use the ‘Enable custom display configuration‘ option on the Advanced step and insert the following:

{ "status_title_invalid":"On-Site Registrant", "status_color_invalid":"#ffff80"
}

 

2) Adding contextual information to the response.

Pattern:

Recorded(.*?)

Replacement:

Attendee $(SCAN_VALUE) has been added to your leads.

Since the word ‘Recorded’ is always in the response text for record-only services, if the scan value was ‘123’ then the response text would now show ‘Attendee 123 has been added to your leads.’ If the scan value was ‘John Doe’, then the response text would now show ‘Attendee John Doe has been added to your leads.’

You can add HTML to the replacement string to alter the view, including highlighting specific text, increasing font sizes or adding colors.

Example B

Change the response for validation services which have ‘Invalid Duplicate’ as the standard response.

Invalid Response, Standard + Altered

Pattern:

^Invalid duplicate.(\r\n|\r|\n)([\s\S]*)(\r\n|\r|\n?)([\s\S]*?)$

Replacement:

<html> <head> <meta name="viewport" content="initial-scale=1" /> </head> <body style="background:yellow"> <h1>Duplicate Ticket!</h1> <p style="color:rgb(140,140,140)">$2</p> <p style="color:rgb(140,140,140);border:thin solid white;padding:5px">$4</p> </body> </html>

 

Example C

Changing the structure of the scanned data.

Pattern:

(.*?),(.*?)$

Replacement:

<html><h2>Last Name: $2</h2><h2>First Name: $1</h2></html>

If the barcode value in the validation database is ‘John,Doe’ then the response text displayed to the app user will be:
Last Name: Doe
First Name: John

Example D:  Catch-All Pattern

If you don’t have a defined pattern in your original, default response text you can use this ‘catch all’ script.

Pattern:

^([\s\S]*)$
\s Matches any whitespace character (spaces, tabs, line breaks).\S Matches any character that is not a whitespace character (spaces, tabs, line breaks).

Response (example):

<html> <head> <meta name="viewport" content="initial-scale=1" /> </head> <body style="background:yellow"> <h1>OFFER STATUS</h1>
<p style="color:green;border:thin solid black;background:white;padding:5px">GREEN = APPROVED</p> <p style="color:red;border:thin solid black;background:white;padding:5px">RED = REJECT (Invalid or duplicate)</p> </body> </html>

 

alter_scan_offer_combined

Example E : Add barcode value to URL

Pattern:

^([\s\S]*)$

Replacement:

<curl>https://www.example.com?barcode=__SCAN_VALUE__</curl>

In this case, the barcode value is added to the base URL and will open automatically in-app.

Example F : Copy URL from scanned value to open in response text.

Pattern:

^([\s\S]*)$

Replacement:

<curl>__SCAN_VALUE__</curl>

In this case, the scanned URL is copied to the Response text field and will open automatically in-app.

If you need assistance, please feel free to email support@codereadr.com – we’re happy to help.

 

in Services