Knowledgebase

Normalization Patterns

I. 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 valus, 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 the 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.

II. Alter Response Value

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 oes 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's some simple examples to demonstrate the concept: 

Example A

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

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>
lt;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 B

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 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

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


Related entries:


Contact Us