VoxCommando Forum

Help and Support (Using VoxCommando) => VoxCommando Basics and Core Features => Topic started by: Oktane83 on March 29, 2014, 11:56:20 PM

Title: Regex Replace
Post by: Oktane83 on March 29, 2014, 11:56:20 PM
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
Title: Re: Regex Replace
Post by: nime5ter on March 30, 2014, 01:05:30 AM
? 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>
Title: Re: Regex Replace
Post by: Oktane83 on March 30, 2014, 12:06:47 PM
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
Title: Re: Regex Replace
Post by: jitterjames on March 30, 2014, 12:18:07 PM
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
Title: Re: Regex Replace
Post by: garryjw on March 30, 2014, 08:13:13 PM
...and mine - great quote.