[Home] [Downloads] [Search] [Help/forum]

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  omiting/replacing certain strings quickly

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

omiting/replacing certain strings quickly

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page


Posted by Oriol   (31 posts)  [Biography] bio
Date Sun 09 May 2010 08:54 AM (UTC)  quote  ]
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?
[Go to top] top

Posted by Twisol   USA  (2,230 posts)  [Biography] bio
Date Reply #1 on Sun 09 May 2010 09:17 AM (UTC)  quote  ]
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
[Go to top] top

Posted by Nick Gammon   Australia  (18,797 posts)  [Biography] bio   Forum Administrator
Date Reply #2 on Sun 09 May 2010 10:40 AM (UTC)  quote  ]
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
[Go to top] top

Posted by Oriol   (31 posts)  [Biography] bio
Date Reply #3 on Sun 09 May 2010 12:16 PM (UTC)  quote  ]
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.
[Go to top] top

Posted by Nick Gammon   Australia  (18,797 posts)  [Biography] bio   Forum Administrator
Date Reply #4 on Sun 09 May 2010 08:16 PM (UTC)  quote  ]
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
[Go to top] 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.


1,143 views.

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]