mababu
(Manjunath Babu)
1
Hello,
I have a very simple doubt. I’m unable to use string replace on the output of IntegerName function.
StringReplace[IntegerName[35], "-" -> " "]
"thirty-five"
Its wrong in the above output. But its correct in the below one.
StringReplace["abba-abbaa", "-" -> " "]
"abba abbaa"
neils
(Neil Singer)
2
when things like this happen you should look at the fullform and it gives the answer:
IntegerName[35] // FullForm
returns
“thirty\[Hyphen]five”
while
"aaa-gff" // FullForm
returns
“aaa-gff”
You need to replace the [Hyphen] character. Type that in your string instead of the dash.
sghuisman
(Sander Huisman)
3
As Neil proposed: FullForm is a good way. Alternatively check the character codes:
ToCharacterCode[IntegerName[35]]
ToCharacterCode["-"] (* a dash *)
{116, 104, 105, 114, 116, 121, 8208, 102, 105, 118, 101}
{45}
a high number generally means it is a ‘special’ character…
If you copy the actual dash and paste that it will work, as Sander points out it isn’t actually a hyphen.
mababu
(Manjunath Babu)
5
It worked. Thank you.
In: StringReplace[IntegerName[35, "Words"],
FromCharacterCode[8208] -> " "]
Out: thirty five