Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ General ➜ omiting/replacing certain strings quickly

omiting/replacing certain strings quickly

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Oriol   (31 posts)  Bio
Date Sun 09 May 2010 08:54 AM (UTC)
Message
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?
Top

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #1 on Sun 09 May 2010 09:17 AM (UTC)
Message
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.

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #2 on Sun 09 May 2010 10:40 AM (UTC)
Message
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.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Oriol   (31 posts)  Bio
Date Reply #3 on Sun 09 May 2010 12:16 PM (UTC)
Message
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.
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #4 on Sun 09 May 2010 08:16 PM (UTC)
Message
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.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


17,926 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.