I want to get the first character from a string in a cell.
"Left" function seemed to worked fine, but it returned questions for emoji.
To extract the first one:
=REGEXEXTRACT(A1,"^.")
Unicode of first value:
=UNICODE(REGEXEXTRACT(A1,"^."))
For me the solution were to use
=char(code(A1))
code - returns the first char unicode value and then I convert it back.
Related
The title says it all. One thing I want to avoid is long formulas. If it's more than a single function, something is clearly wrong since this should be a common use case.
I've tried TO_PURE_NUMBER and VALUE
Your question suggests that the value $71.4145 is not a number but a text string. That can happen if your spreadsheet locale is such that it expects comma as decimal mark, or expects a different currency symbol. It will also happen if you have formatted the value as plain text rather than currency.
To convert the text string $71.4145 into the number 71.4145 (seventy-one and change), use regexextract(), like this:
=iferror( value( regexextract( to_text(A2), "[\d.]+" ) ) )
Just use -- to suppress text to equivalent number values. Try-
=--A1
try:
=SUBSTITUTE(A1; "$"; )*1
I want to remove the first and last characters of a text in a cell. I know how to remove just the first or the last with formulas such as =LEFT(A27, LEN(A27)-1) but i want to combine two formulas at the same time for first and last character or maybe there is a formula that I'm not aware of which removes both (first and last characters) at the same time.
I know about Power Tool but i want to avoid using this tool and I'm trying to realize this simply by formulas.
You could use the REGEXREPLACE() function:
=REGEXREPLACE(A27, "^.|.$", "")
The regular expression used here matches:
^. the first character after the start of the string
| OR
.$ the last character of the string
better not to use this but it works too:
=RIGHT(LEFT(A27, LEN(A27)-1), LEN(LEFT(A27, LEN(A27)-1))-1)
=LAMBDA(x, RIGHT(LEFT(A27, x), LEN(LEFT(A27, x))-1))(LEN(A27)-1)
=LAMBDA(x, LAMBDA(y, RIGHT(y, LEN(y)-1))(LEFT(A27, x)))(LEN(A27)-1)
=LAMBDA(x, RIGHT(x, LEN(x)-1))(LEFT(A27, LEN(A27)-1))
I need a Google Sheet function that will return the position of the last instance of a particular character. Basically, FIND, but starting on the right.
For example, for the data set below, I need to return the position of the last dash.
ABC-DEF-GHI = 8
ABCD-EF-GH-IJK = 11
AB-C-DE-FGH-I-JK = 14
Thanks!
I don't know where to start. MID might work, but the file names are of different lengths and different formats. The files just generally end with - ***.png, and I need the asterisk. The string I need is also of variable length and can contain spaces (the string is the name of the student).
Here's a possible solution:
=len(regexextract(A1,".*-"))
It's essentially extracting everything up to the last dash and taking the length of the resulting string.
for the whole array try:
=INDEX(LEN(REGEXEXTRACT(A1:A3; "(.*-)")))
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.
After many hours I finally figured out how to import data from <span>...
Yet right now I've hit next wall and I can't figure out what can help me in this situation.
After using:
=IMPORTXML("https://www.bodypak.pl/pl/aminokwasy/5890-6pak-nutrition-bcaa-pak-400g.html";"//span[#id='our_price_display']")
As result, we have 79,00 PLN, yet that is String and I can't figure out how to convert it to INT
For making everything easier cell where I'm importing data I will mark as #XML =Value('#XML')
don't work, same implemented formatting.
I also tried to export the result to another cell and format another cell but that didn't work either.
=LEFT(#XML,LEN(#XML)-3) leave me with 79,00 but still I can't convert it to Int.
And I'm quite stuck right now.
You can use the function split like this: split(str, separator, 0) and take the first item of the resulting array with
=index(split(arr,","),0,1)
All together:
=index(split(split(IMPORTXML("https://www.bodypak.pl/pl/aminokwasy/5890-6pak-nutrition-bcaa-pak-400g.html","//span[#id='our_price_display']")," "),","),0,1)
The formula above truncates the string at the ",". If you want to actually convert to integer, use int() after replacing the comma with a ".":
=int(value(substitute(split(IMPORTXML("https://www.bodypak.pl/pl/aminokwasy/5890-6pak-nutrition-bcaa-pak-400g.html","//span[#id='our_price_display']")," "),",",".")))