Announcement

Collapse
No announcement yet.

string search & replace

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • string search & replace

    I was wondering if there was a way to have wildcards in a search and replace function? -- Preferably in a string. What I'm trying to do is seperate a filename (name.ext) and convert it to a list box entry with the format (name::ext). The only ceavat that I'm running into is some filenames may have periods in them somewhere else... (file.name.ext)--so a simple search and replace won't exactally work...
    What I have right now is:

    <font color=green>
    <IR_ACTIONS_LIST>
    <Action name="Replace">
    <Type>60</Type>
    <Function>0</Function>
    <DTIndentLevel>2</DTIndentLevel>
    <Enabled>1</Enabled>
    <ErrorHandling>
    <UserNotificationMode>2</UserNotificationMode>
    <CustomErrorMessage/>
    <OnErrorAction>0</OnErrorAction>
    <JumpToLabel/>
    </ErrorHandling>
    <Variable>%LineAdd%</Variable>
    <SearchIn>%LineName%</SearchIn>
    <SearchFor>.</SearchFor>
    <ReplaceWith>::</ReplaceWith>
    <CaseSensitive>1</CaseSensitive>
    </Action>
    </IR_ACTIONS_LIST>
    </font color=green>

    Thanks in advance!

  • #2
    Re: string search &amp; replace

    I think yu have only given us half the Actions yur using, here .. in any case, something like the following will work:


    %filename%=String.ParsePath[%variable%,Filename]
    %ext%=String.ParsePath[%variable%,FileExtension]
    %CustomVar%=Evaluate[%filename%-%ext%]


    This will break down the filename and extension for yu. If you want to get rid of the periods in the filename from there, just use a String Replace changing "." for nothing

    FYC:
    <font color=green>
    <IR_ACTIONS_LIST>
    <Action name="Parse Path">
    <Type>62</Type>
    <Function>0</Function>
    <DTIndentLevel>0</DTIndentLevel>
    <Enabled>1</Enabled>
    <ErrorHandling>
    <UserNotificationMode>2</UserNotificationMode>
    <CustomErrorMessage/>
    <OnErrorAction>0</OnErrorAction>
    <JumpToLabel/>
    </ErrorHandling>
    <Variable>%filename%</Variable>
    <Source>%file%</Source>
    <ParseType>4</ParseType>
    </Action>
    <Action name="Parse Path">
    <Type>62</Type>
    <Function>0</Function>
    <DTIndentLevel>0</DTIndentLevel>
    <Enabled>1</Enabled>
    <ErrorHandling>
    <UserNotificationMode>2</UserNotificationMode>
    <CustomErrorMessage/>
    <OnErrorAction>0</OnErrorAction>
    <JumpToLabel/>
    </ErrorHandling>
    <Variable>%ext%</Variable>
    <Source>%file%</Source>
    <ParseType>5</ParseType>
    </Action>
    <Action name="Set Value">
    <Type>6</Type>
    <Function>0</Function>
    <DTIndentLevel>0</DTIndentLevel>
    <Enabled>1</Enabled>
    <ErrorHandling>
    <UserNotificationMode>2</UserNotificationMode>
    <CustomErrorMessage/>
    <OnErrorAction>0</OnErrorAction>
    <JumpToLabel/>
    </ErrorHandling>
    <Variable>%CustomVar%</Variable>
    <Value>%filename%-%ext%</Value>
    <Evaluate>1</Evaluate>
    </Action>
    <Action name="Replace">
    <Type>60</Type>
    <Function>0</Function>
    <DTIndentLevel>0</DTIndentLevel>
    <Enabled>1</Enabled>
    <ErrorHandling>
    <UserNotificationMode>2</UserNotificationMode>
    <CustomErrorMessage/>
    <OnErrorAction>0</OnErrorAction>
    <JumpToLabel/>
    </ErrorHandling>
    <Variable>%NewString%</Variable>
    <SearchIn>%CustomVar%</SearchIn>
    <SearchFor>.</SearchFor>
    <ReplaceWith/>
    <CaseSensitive>1</CaseSensitive>
    </Action>
    </IR_ACTIONS_LIST>

    </font color=green>
    -
    = Derek
    ["All glory comes from daring to begin" - fortune cookie]

    Comment


    • #3
      Re: string search &amp; replace

      Alright I finally got it, and It is pretty simple too! (well number of commands wise)

      This is what I did for the curious:

      <font color=green>
      <IR_ACTIONS_LIST>
      <Action name="Parse Path">
      <Type>62</Type>
      <Function>0</Function>
      <DTIndentLevel>2</DTIndentLevel>
      <Enabled>1</Enabled>
      <ErrorHandling>
      <UserNotificationMode>2</UserNotificationMode>
      <CustomErrorMessage/>
      <OnErrorAction>0</OnErrorAction>
      <JumpToLabel/>
      </ErrorHandling>
      <Variable>%LineName%</Variable>
      <Source>%FullLine%</Source>
      <ParseType>4</ParseType>
      </Action>
      <Action name="Parse Path">
      <Type>62</Type>
      <Function>0</Function>
      <DTIndentLevel>2</DTIndentLevel>
      <Enabled>1</Enabled>
      <ErrorHandling>
      <UserNotificationMode>2</UserNotificationMode>
      <CustomErrorMessage/>
      <OnErrorAction>0</OnErrorAction>
      <JumpToLabel/>
      </ErrorHandling>
      <Variable>%ext%</Variable>
      <Source>%FullLine%</Source>
      <ParseType>5</ParseType>
      </Action>
      <Action name="Set Value">
      <Type>6</Type>
      <Function>0</Function>
      <DTIndentLevel>2</DTIndentLevel>
      <Enabled>1</Enabled>
      <ErrorHandling>
      <UserNotificationMode>2</UserNotificationMode>
      <CustomErrorMessage/>
      <OnErrorAction>0</OnErrorAction>
      <JumpToLabel/>
      </ErrorHandling>
      <Variable>%LineAddA%</Variable>
      <Value>%LineName% - (. + %ext%)</Value>
      <Evaluate>1</Evaluate>
      </Action>
      <Action name="Set Value">
      <Type>6</Type>
      <Function>0</Function>
      <DTIndentLevel>2</DTIndentLevel>
      <Enabled>1</Enabled>
      <ErrorHandling>
      <UserNotificationMode>2</UserNotificationMode>
      <CustomErrorMessage/>
      <OnErrorAction>0</OnErrorAction>
      <JumpToLabel/>
      </ErrorHandling>
      <Variable>%LineAdd%</Variable>
      <Value>%LineAddA% + :: + %ext%</Value>
      <Evaluate>1</Evaluate>
      </Action>
      </IR_ACTIONS_LIST>
      </font color=green>

      Comment


      • #4
        Re: string search &amp; replace

        Cool! Someone actually used string subtraction. [img]/ubbthreads/images/icons/smile.gif[/img]
        --[[ Indigo Rose Software Developer ]]

        Comment


        • #5
          Re: string search &amp; replace


          Derek,

          Superb ! I hadn't explored those drop down boxes, I was amazed.

          Nice work.

          Comment


          • #6
            Re: string search &amp; replace

            I'm sure, at one point, I thought it would be a good idea to have the ability to count the number of times a certain character is used in a string [in one Action]

            String.CountChar,"Q"

            Perhaps it could be added? [img]/ubbthreads/images/icons/smile.gif[/img] [with a choice to start the counting from the left or the right]
            -
            = Derek
            ["All glory comes from daring to begin" - fortune cookie]

            Comment

            Working...
            X