How to return letters between points using a regular expression?

Asked

Viewed 363 times

0

I am using Google Drive and would like to use a regular expression to separate characters between points, as below :

the Bai Xa men to
the Bai Xo

I need to put in each column, the content between the points (in the first and last case only before and after the point).

a Bai Xa men to => a Bai Xa men to

to Bai Xo => to Bai Xo

I would need a code for each "answer" column For example the Bai Xa men to (a) first letter before the point (b)letter between the first 2 points (c) letter between the second and third point etc.

  • 3

    It does not say what language you want to use (apart from mentioning Regex), but assuming C# for example, you can simply split the string by dots "a·bai·xa·men·to".Split('.') \\ retorna um array de strings.

  • Oh, it was bad. I’m using google drive. I wanted to put the regular expression inside the formula already available. Like this example below. -on-demand (male name) =REGEXEXTRACT(A3;" [ ()]*") -on-demand In case I need a command for each column where the words will return between the dots(imagine 8 or 9). Valeu!!

  • Need regex? You can go to Menu -> Data -> Split Text Into Columns (ai chooses the tab), or use the function =SPLIT(coluna, ".")

2 answers

1

Simply use [^\.]+

This regex will take everything that is not a point.

However what you suggest to enumerate each group of characters is not possible as regex cannot "count".

At most you can catch the first group with ^[^\.]+ and the last with [^\.]+$.

Otherwise I suggest you make a program that consumes the string at each point and counting, it is very easy.

  • No need to escape the . if you are inside a character set [].

0

I’m no expert on regular expressions, but I believe the expression would look like this:

[a-z]

  • It did not work, :( I would need a code for each column of the "answer" For example the Bai Xa men to (a) first letter before the point (b)letter between the first 2 points (c) letter between the second and third point etc..

Browser other questions tagged

You are not signed in. Login or sign up in order to post.