How to Remove Numeric Strings in Perl

Perl is an open-source, programming language known for its powerful functions for manipulating text, strings and numbers. When programming in Perl, you may need to strip a string of numeric characters. For example, you may have a user's ID that consists of numbers and letters. To create an updated ID, you need to remove all numeric characters.

Instructions

    • 1

      Open your program in your Perl editor.

    • 2

      Remove all numeric characters by typing the following:

      $stringUser_ID = s / ^ \ d//g;

    • 3

      Save your program.

      In this example, Perl searches the string at the beginning, " / ^ \" , finds any digits , "\ d" and deletes the digit. The global modifier, "//g" tells Perl to look for numbers throughout the entire string, instead of stopping at the first instance of a number.

Related Searches:

References

Comments

Related Ads

Featured