News:

VoxCommando supports plugins for a wide variety of programs and devices. Contact us if you want to create your own.

Main Menu

Regex Replace

Started by Oktane83, March 29, 2014, 11:56:20 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Oktane83

Can't figure this dammn thing out. All I want to do is Replace an "a" with a "b". And an "/" to "/ ".Just adding a space in front.

:bonk

nime5ter

#1
? Do you mean a space after the slash? In your quotes it looks like there's a space after.

Is the "a" in the middle of a word or on its own?

It's almost always best to post your xml so we can see the context. Maybe the following will help but it's hard to tell without knowing the context.
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 1.9.1.9-->
<command id="270" name="a to the b" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="Results.Replace (no regular expression) is sometimes enough, and sometimes easier. Sometimes not.&#xD;&#xA;&#xD;&#xA;The 2nd, &quot;replace with&quot;, parameter in Results.RegExReplace does not take regular expressions. So if you want spaces around your b, put spaces around your b.">
  <action>
    <cmdType>Results.SetLastResult</cmdType>
    <params>
      <param>I am a on my own.</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>OSD.ShowText</cmdType>
    <params>
      <param>{LastResult}</param>
      <param>10000</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.Replace</cmdType>
    <params>
      <param> a </param>
      <param> b </param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>OSD.AddText</cmdType>
    <params>
      <param>{LastResult}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.SetLastResult</cmdType>
    <params>
      <param>I am ab when I should be just b. But fab is still fab.</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>OSD.AddText</cmdType>
    <params>
      <param>{LastResult}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.RegExReplace</cmdType>
    <params>
      <param>(\sab\s)</param>
      <param> b </param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>OSD.AddText</cmdType>
    <params>
      <param>Now, {LastResult}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.SetLastResult</cmdType>
    <params>
      <param>Sometimes "results.replace" is/a/better choice than "results.regex".</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>OSD.AddText</cmdType>
    <params>
      <param>{LastResult}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.Replace</cmdType>
    <params>
      <param>/</param>
      <param> / </param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>OSD.AddText</cmdType>
    <params>
      <param>{LastResult}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
</command>
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

Oktane83

Ok ill play around with that when I get off work. Again thank you guys for all the help. This programming, if I can call it that is really fun, but absolutely maddening at the same time. Mostly because I have no idea what I'm doing lol.  :D

jitterjames

Quote from: Oktane83 on March 30, 2014, 12:06:47 PMThis programming, if I can call it that is really fun, but absolutely maddening at the same time. Mostly because I have no idea what I'm doing lol.  :D

That pretty much sums up my life.  ::hmm

garryjw

...and mine - great quote.