omiting/replacing certain strings quickly

Posted by Oriol on Sun 09 May 2010 08:54 AM — 5 posts, 18,803 views.

#0
Hi all:
I play a spanish mud with a screen reader and I needed to change the commas in decimal places for points so my reader would read them right..
I tried making a re with somethin glike (\d+),(\d+) but it would only do one comma and not the others.
An example of this would be somethign like
"Tienes 2,256,293,295 monedas de oro.
And I wanted the change the , for a . I was thinking on perhaps matching on every line and converting the number to string and string replacing it, but that's too much processing probably. Has anyone got a better idea?
Also, a friend needed to omit | and [ ] * in strings. Maybe ti could be done with the same process?
USA #1
In regard to the commas, a trigger like that should work just fine as long as you check "Repeat on same line" for the trigger. That would probably help with your | [ ] * thing as well.
Australia Forum Administrator #2
Oriol said:

An example of this would be somethign like
"Tienes 2,256,293,295 monedas de oro.


Hola!

"Repeat on same line" is only for colouring matching lines.

Oriol said:

... but that's too much processing probably.


Well, not really. It can handle quite a bit of processing. You could make a trigger that matches something like (\d+),(\d+) (like you said) and then omit it from output. Then in Lua, do a string.gsub to change the commas to dots. Or if you are using a screen reader anyway, do this only in the function that calls the screen reader (this would not need you to omit from output).

A bit depends on how the screen reader is called, but is should be simple, really.
#3
Hi.
The problem with using a trigger like (\d+),(\d+) is taht it'd only work for numbers with one comma in them.
like 1,325 would match, but 2,325,982 would not, nor would 3,248,329,565. I'd need to create multiple triggers which do the same thing. Also, there can be text before and after the number of course.
Australia Forum Administrator #4
The trigger simply detects that there is at least one number followed by a comma, followed by another number.

The string.gsub in the script then replaces *all* sequences of number-comma-number into number-dot-number.

In any case, you need to look into how does the text reach the screen reader. If that is inside a scripted plugin, you don't need a trigger at all. Simply have the plugin replace number-comma-number by number-dot-number before sending the text to the speaking routine.