Home

OFF-SOFT.net

OFF-SOFT.net

This site is support & information site of WEB,and Software. This site might help you that create software or Web Site…perhaps?[:]

ssmacro.replace Command

ssmacro.replace Command

This is replace command that can use in ssmacro macro file. Also this command can use regular replace by RegExp(Javascript).

Parameter

  • find string (This is find letters. not set is error)
  • replace string (This is replace letters. not set is error)
  • all [true|false] (This is replace range. not set or parameter error is the selected range)
    Note, this flag does not mean all replace hit words. This is search start position.
  • reg [true|false] (This is regular expression of find. not set or parameter error is not regular)
  • flag string (This is regular expression flags. not checked)
    This will be used by RegExp (Javascript).

Example

1st step, you should create a macro file( see the page about macro file format detail ).

[
    {
        "args":
        {
            "find": "(parameter.*?)\[(.*?)\]",
            "replace": "__$1[^^$2^^]__",
            "all":true,
            "reg":true,
            "flag":"gmi"
        },
        "command": "ssmacro.replace"
    },
    {
        "args":
        {
            "find": "ssmacro",
            "replace": "__ssmacro__",
            "all":true,
            "reg":false,
            "flag":""
        },
        "command": "ssmacro.replace"
    }
]

2nd step, you will execute it macro file by ssmacro.run command.
executing image
1st replace, "flag" set "gmi", and "reg" is true.

  • g global match; find all matches rather than stopping after the first match
  • i ignore case
  • m multiline; treat beginning and end characters (^ and $) as working over multiple lines (i.e., match the beginning or end of each line (delimited by \n or \r), not only the very beginning or end of the whole input string)

Source : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp

2nd replace, "reg" is false. This mean replace only first hit word. If you want replace all hit words, you should use regular and "flag" will add "g".




  • はてなブックマークへ追加する
  • Facebookでシェアする
  • twitter でつぶやく
  • Google Plusでシェアする
  • Pocketでシェアする
ページトップへ