# Posted By

bvwatson on 05/28/15

# Statistics

Viewed 681 times
Favorited by 0 user(s)

# RegEx string substitution

/ Published in: Perl

[The original problem was stated as a SQL (SQL Server 2008) problem. This Perl script demonstrates the desired outcome for the problem statement.]

PROBLEM STATEMENT:

Below is the Data and I have to remove all texts associated with numbers. If incase in between LETTERS if we see number or numbers, those also should be removed, for ex:A2D104380, here A2D should be removed, others only letters.

Field_Name

AS76573

AEDFG103020

A2D104380

S103282

Yes you are correct but gain if exists number and again followed by any
letters then number also should be removed.

For ex: ASD6D6383884

Here ASD6D should be removed.
GH63737. Here only GH should be removed

SOLUTION RESULTS:

Word 1 = AS76573 -> 76573

Word 2 = AEDFG103020 -> 103020

Word 3 = A2D104380 -> 104380

Word 4 = S103282 -> 103282

Word 5 = ASD6D6383884 -> 6383884

Word 6 = GH63737 -> 63737

Word 7 = AS76573AEDFG103020A2D104380S103282ASD6D6383884GH63737 -> 76573103020104380103282638388463737

Copy this code and paste it in your HTML
`#!/usr/bin/perl @words = qw (AS76573              AEDFG103020              A2D104380              S103282              ASD6D6383884              GH63737              AS76573AEDFG103020A2D104380S103282ASD6D6383884GH63737             ); # RETRIEVE DATA AND APPLY MODS\$pkey = 0;foreach \$orig_word(@words){  \$pkey++;  \$new_word = \$orig_word;  \$new_word =~ s/([a-zA-z][0-9][a-zA-Z]|[^\d])//g;  print "\nWord \$pkey = \$orig_word -> \$new_word\n";}# done --`