Is there a way to remove some occurrence of a variable within a text without knowing where the variable is in the text ?

e.g :

IP= DA, null,

var to be removed from the text : ", null,"

I know in this actual example I could trim using this

set newText to text 1 thru -8 of var1

Or even with a text delimiter, but I need to remove the variable from a random text without knowing where the variable is within the text

  • 2
    Why AppleScript? BTW "IP= DA, null," is not an AppleScript method of assigning the value of a variable. I'd use sed, e.g. sed 's/, null,//' where e.g., sed 's/, null,//'<<<'IP= DA, null,' returns: IP= DA – user3439894 Mar 4 '19 at 17:14
  • Thank you. how would I place the variable on the sed command ? I tested with : do shell script "sed 's/, null,//' <<<" & input but this return an error. (PS my text is a long text generated by the same AppleScript with including IP= RANDOM, null, within the text) – Kevin Mar 4 '19 at 17:36
  • Never-mind, it's working : do shell script "sed 's/, null,//' <<<'" & input & "'" Thank you again – Kevin Mar 4 '19 at 17:39

You must log in to answer this question.

Browse other questions tagged .