-1

i want to edit only alphabetic charcter from my cell . what i have done

value.match(/.*?(\^[a-zA-Z]*$).*?/)

but it returns null

i am try to clean address column in my data set following are the sample address

H3656 GALI#4 BLOCK-D, AREA 1

H#36/17 SECTOR 5D AREA 2

AREA 3 BLOCK-B NORTH NAZIMABAD

GERMANY AL JANNAT BENQUET SECTOR 16 Area 2 with short name

so that i first try to remove all numbers from my string

Usman Asif
  • 320
  • 2
  • 12

1 Answers1

1

If you want to remove all the numbers, the most direct approach is probably:

value.replace(/\d+/, "")

enter image description here

If for any reason you want to find only the alphabetic characters, as indicated by the title of your question, this will be more effective than a value.match() :

value.find(/\p{L}\s?/).join("")

(\p{L} is a Java regular expression - Openrefine is written in Java - equivalent to [a-zA-Z], but which also takes into account Unicode characters like accented letters.)

In general, you should avoid using the .match() method unless you know exactly what you are doing. In 90% of cases, it is actually .find() that is desired.

Ettore Rizza
  • 2,800
  • 2
  • 11
  • 23
  • can you also please guide about solution of my problem. as you know its data cleaning problem. am i on right direction b/c my ultimate problem is finding a area – Usman Asif Nov 23 '19 at 19:52
  • I did'nt understand that your problem is finding an area. Your questions are about alphabet and numbers, the word "area" is not mentioned at all. What's exactly what you want to find in those strings? Do you want to get the parts in bold? – Ettore Rizza Nov 23 '19 at 20:22
  • yes exactly i want that part which is bold area means location (that is address of person) i just want to grab location/vicinity/arear of a person and make analysis on that person – Usman Asif Nov 23 '19 at 20:29
  • Could you edit/elaborate your question and provide a real example? Based on your examples, looks like you want the word AREA followed by a number, or the Word area followed by a number and the rest of the string, or you don't want the word area at all if it's followed by 1. it's really unclear. – Ettore Rizza Nov 23 '19 at 20:33