reg exp question

L

laredotornado

Hi,

If I have a variable @fax, how can I apply a regular expression to the
variable such that all non-numeric characters are removed? You can
assume the fax number is of a valid US format.

Thanks, - Dave
 
7

7stud --

laredotornado said:
If I have a variable @fax, how can I apply a regular expression to the
variable such that all non-numeric characters are removed? You can
assume the fax number is of a valid US format.

str = '1234abc5d6e7f8ghi'

result = str.gsub(/\D/, "")
puts result

--output:--
12345678
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top