Announcement

Collapse
No announcement yet.

Regex Replacement + Replacement on selection

Collapse
X
 
  • Time
  • Show
Clear All
new posts

  • Regex Replacement + Replacement on selection

    Hi,

    I'm using BC_3.0.13. I'm working on shell scripts & I had to comment a line. What I did was I selected the line & fired the Replace "^" with "#" (with Regular Expression box checked) command. Now I have two concerns -
    1. The Replace dialog didn't have any option which works only on selection. That's the most desirable thing to have. Please include it.
    2. Nonetheless assuming the replace dialog will replace the whole file ..it came out with Text "^" not found error. Strange !!

  • #2
    1. Replacements affect the entire file. It isn't possible to set a replacement that is limited to a selection.

    2. "^" is a special character in regular expressions that indicates the beginning of a line. Try escaping it and using "\^" to match on the caret character.

    Edit:
    Please ignore this, I thought you were referring to the "Replacements" tab in Session > Session Settings, not "Search > Replace".
    Last edited by Chris; 07-Jan-2009, 05:14 PM.
    Chris K Scooter Software

    Comment


    • #3
      Here's another try, for "Search > Replace":

      1. Search > Replace doesn't have a "just selection" option, I'll add it to our wish list.

      2. To insert a # in front of lines, check "Regular Expression", then use "(.*)" as the text to find. The ".*" matches on the whole line, the parenthesis save the matched text. The matched text is saved in the variable $1, so use the replacement text "#$1".
      Chris K Scooter Software

      Comment


      • #4
        Thanks Chris! You suggestion helps.

        Comment


        • #5
          Originally posted by Chris
          1. Search > Replace doesn't have a "just selection" option, I'll add it to our wish list.
          Thanks. I, too, have asked for this in the past. Nice to know that it finally made the wish list.
          BC v4.0.7 build 19761
          ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

          Comment

          Working...
          X
          😀
          🥰
          🤢
          😎
          😡
          👍
          👎