These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

extract numeric string from a string

lopi007
Registered: Jul 7 2011
Posts: 11

Hi everyone,
I need advice, I have a field named: "address". Value is the name of the street plus a house number (ex. Wall Street 1248). I need to extract from this string, specifically the street (Wall Street) and especially the house number (1248). How? I use AcrobatX.
I thank everyone in advance for your help.
Lopi007

My Product Information:
Acrobat Pro 10.1, Windows
lopi007
Registered: Jul 7 2011
Posts: 11
Hi everyone,
I need advice, I have a field named: "address". Value is the name of the street plus a house number (ex. Wall Street 1248/456). I need to extract from this string, specifically the street (Wall Street) and especially the house number (1248/456). How? I use AcrobatX.
I thank everyone in advance for your help.


try67
Expert
Registered: Oct 30 2008
Posts: 2398
It's a but tricky, but you can try something like this:

  1. var str="Wall Street 1248/456";
  2. var patt1=/[\d\/]+/;
  3. var houseNumber = str.match(patt1);
  4. var street = str.replace(m,"");

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
Just becareful of numeric street names like "2nd Ave 1248/456".



George Kaiser

try67
Expert
Registered: Oct 30 2008
Posts: 2398
Or when someone writes the house number before the street name, like "12 Main St." ...
(edit: in second thought, it should work in those instances as well)

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

lopi007
Registered: Jul 7 2011
Posts: 11
SOLVED!
so I'm going perfectly

var adresa = this.getField("01").value;
var cislo = /[\d$\/]+[^\D]+[^ ]+$/;
var vUlice = /[\^0-9\\.]*[\D][^ ]+/;
var cDomu = adresa.match(cislo);
var ulice = adresa.match(vUlice);
this.getField("02").value = ulice;
this.getField("03").value = cDomu;