Regex to extract first part of string in Apache Pig -


i need extract post code district input data below

ab55 4 dd7 6ll dd5 2hi 

my code

a = load 'data' postcode:chararray; b = foreach { code_district = regex_extract(postcode,'<some exp>',1); generate code_district; }; dump b; 

output should like

ab55 dd7 dd5 

what should regular expression extract first part of string?

can try below regex?

option1:

a = load 'input' postcode:chararray; code_district = foreach generate regex_extract(postcode,'(\\w+).*',1); dump code_district; 

option2:

a = load 'input' postcode:chararray; code_district = foreach generate regex_extract(postcode,'([a-za-z0-9]+).*',1); dump code_district; 

output:

(ab55) (dd7) (dd5) 

Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -