how to extract comma separated values separately in Erlang - erlang

I have inserted the comma separated values into mnesia table column as {"11,1,15"}
After retrieving from table Now i need to extract these comma separated values. while extracting these 11,1,15 as separate values, I am getting problem, because it returning value in below format.
49 | 1,1,12.
But here i need them separately as integer digits.
Can you point me in correct direction? where I am making mistake?

If you want to convert a string of comma separated integers into a list of integers, this can help:
1> String = "11,1,15".
"11,1,15"
2> [list_to_integer(I) || I <- string:tokens(String,",")].
[11,1,15]

Related

Google Sheets Extract Text between two characters

I have a field where I need to extract the text between two characters.
I've found regexextract and I got it to work when there is one character but I can't for the life get it to work with multiple characters.
2020-02: Test Course (QAS)
I need to extract text after : and before (
So it would just return "Test Course"
TYIA
If it's for just one cell (say A2):
=IFERROR(TRIM(REGEXEXTRACT(A2,":([^\(]+)")))
This will return what you want regardless of spaces after the colon or before the opening parenthesis. If no match is found, null will be returned.
If it's to process an entire range (say, A2:A), place the following in, say, B2 of an otherwise empty Col B:
=ArrayFormula(IF(A2:A="",,IFERROR(TRIM(REGEXEXTRACT(A2:A,":([^\(]+)")),A2:A)))
This will return what you want regardless of spaces after the colon or before the opening parenthesis. If no match is found, the original string will be returned.
In both cases, the REGEX string...
:([^\(]+)
... means "a grouping of any number of characters that aren't an opening parenthesis and which follows a colon."
One way to do that would be with the INDEX() and SPLIT() functions like this:
=TRIM(INDEX(SPLIT(A2,":("),2)
Split splits the text into 3 parts using the : and (, then INDEX chooses the second part.
The TRIM() just gets rid of the spaces.

Split an a comma seperated list of number like strings as text

I have a column which contains comma seperated numbers
A1: 004,005,0005,00005
I want to split and more stuff with this. When I split I end up with the following. Losing the zeros because excel parses them as text
=split(A1, "," )
4 | 5 | 5 | 5
instead of
004 | 005 | 0005 | 00005
The number of zeros is important. I will pass on the result to get a vertical list
=unique(transpose(arrayformula(trim(split(join(",",!A1:A),",")))))
Adding a single quote before a number will keep the format as is, thus, keeping the leading and trailing zeroes. Please see formula below:
=SPLIT(SUBSTITUTE(","&A1,",","#'"),"#")
Try this:
=ArrayFormula(REGEXREPLACE(SPLIT(REGEXREPLACE(A1,"(\d+)","~$1"),","),"~",""))
What this formula does is first replace every group of numbers with a tilde (~) and that same group of numbers. When SPLIT then acts on this new configuration, splitting at the commas, every group of numbers has the tilde in front of it and so retains all digits (because it is seen as a string and not a number). Finally, the outer REGEXREPLACE just gets rid of the tildes.
With just a single value in A1 you can use a little trick I described over at "Web-Applications" in this cross-website post:
=SPLIT(SUBSTITUTE("'"&A1,"#","#'"),"#")
The single quote will force GS to format the returned elements as being text. We can use this principle inside an arrayformula if you have to concatenate multiple strings. You don't need ARRAYFORMULA() per se, but instead of JOIN() you'd need TEXTJOIN() to use the 2nd parameter and exclude empty cells from being joined.
Formula in B1:
=UNIQUE(TRANSPOSE(SPLIT(SUBSTITUTE("'"&TEXTJOIN(",",TRUE,A1:A),",","#'"),"#")))

Extract substring after '-' character in Google Sheets

I am using the following formula to extract the substring venue01 from column C, the problem is that when value string in column C is shorter it only extracts the value 1 I need it to extract anything straight after the - (dash) no matter the length of the value text in column c
={"VenueID";ARRAYFORMULA(IF(ISBLANK(A2:A),"",RIGHT(C2:C,SEARCH("-",C2:C)-21)))}
There is a much simpler solution using regular expressions.
=REGEXEXTRACT(A1,".*-(.*)")
In case you are no familiar with Regular Expressions what this means is, get me every string of characters ((.*)) after a dash (-).
Example
Reference
REGEXTRACT
Test regular expressions
Cheat sheet for regular expressions
To answer bomberjackets question in the comment of Raserhin:
To select the part of the string before the "-"
=REGEXEXTRACT(A1,"(.*)-.*")
EXAMPLE
example of code
Adding to your original formula. I think if you'd use RIGHT and inside it reverse the order of the string with ARRAY then that may work.
=Right(A1,FIND("-",JOIN("",ARRAYFORMULA(MID(A1,LEN(A1)-ROW(INDIRECT("1:"&LEN(A1)))+1,1))))-1)
It takes string from the right side up to X number of characters.
Number of character is fetched from reversing the text, then finding
the dash "-".
It adds one more +1 of the text as it will take out so it accounts
for the dash itself, if no +1 is added, it will show the dash on
the extracted string.
The REGEX on the other answer works great too, however, you can control a number of character to over or under trim. E.g. if there is a space after the dash and you would like to always account for one more char.

Google Sheets: string to columns and rows

I have a string separated by commas. Easily with split formula I can have each data in separated cells but all the data are in one single row. I need to transform data from this format:
to this format:
where the value in the column F is associated to only one row. So it means that one and only one block of the original string is longer than the others. Following the above screenshots:
1st block of the string:
fubles.com/matches/2655533,Atletico Saraitu,Edoardo Pallavicini,7.38,6,
7th block of the string:
fubles.com/matches/2655533,Atletico Saraitu,Andrea Cissello,7.55,7,Yes,
Is there anyone that can help me to build the right formula?
Thanks
You can do it in 2 parts - first to separate the different rows - then run split again on the rows after you save the values - use substitute or regexreplace to add in a different delimiter, i prefer to use the semicolon:
=transpose(split(REGEXREPLACE(A1,"fubles",";fubles"),";"))
OR
=transpose(split(SUBSTITUTE(A4,"fubles",";fubles"),";"))
They literally do the exact same thing, but essentially you are adding the semicolon in from of your starting string, then you split by that delimiter, the transpose to stack the rows.
You should then COPY and PASTE VALUES to flatten the data - then run your split by comma on all those rows.

How to display parameter value separated by comma in table in rtf using bi publisher

I have tried to use extended function to separate these values but the problem is that I am able to separate only one value.
https://isu.ifmo.ru/docs/XMLP/help/en_US/htmfiles/B25951_01/T421739T421827.htm
You will have to use some text processing functions on each of the parameter. Say, if $name is the parameter which contains the comma separated data, then
<?xdofx:Instr($name,',',1)?> will give you the position of the comma in the text.
Then <?xdofx:substr($name,1, Instr($name,',',1)-1)?> will return the text before the comma.
And. <?xdofx:substr($name,Instr($name,',',1)+1, length($name))?> will return the text after the comma
first,last
6
first
last

Resources