search replace with regex

Discussion in 'Java' started by Roedy Green, Nov 25, 2011.

  1. Roedy Green

    Roedy Green Guest

    I have been using Funduc Search/Replace with works command line, as a
    gui, and with scripts to do multiple search-replaces on multiple
    files.

    It work fine, except it uses a proprietary regex quite different from
    Java Regex. I would like something just like it, but that use Java
    Regex. I have unsuccessfully tried to talk the authors into supporting
    Java syntax.

    see http://mindprod.com/jgloss/searchreplace.html
    to see what I mean.

    I have not found anything suitable is a short google search. On my
    todo list is to write one. What do you use?
    --
    Roedy Green Canadian Mind Products
    http://mindprod.com
    I can't come to bed just yet. Somebody is wrong on the Internet.
    Roedy Green, Nov 25, 2011
    #1
    1. Advertising

  2. On 11-11-25 04:17 AM, Roedy Green wrote:
    > I have been using Funduc Search/Replace with works command line, as a
    > gui, and with scripts to do multiple search-replaces on multiple
    > files.
    >
    > It work fine, except it uses a proprietary regex quite different from
    > Java Regex. I would like something just like it, but that use Java
    > Regex. I have unsuccessfully tried to talk the authors into supporting
    > Java syntax.
    >
    > see http://mindprod.com/jgloss/searchreplace.html
    > to see what I mean.
    >
    > I have not found anything suitable is a short google search. On my
    > todo list is to write one. What do you use?


    On Windows I use Notepad++ or Powershell for the general case (where
    it's _not_ source code in an IDE).

    AHS
    Arved Sandstrom, Nov 25, 2011
    #2
    1. Advertising

  3. Roedy Green

    Roedy Green Guest

    On Fri, 25 Nov 2011 07:24:00 -0400, Arved Sandstrom
    <> wrote, quoted or indirectly quoted
    someone who said :

    >
    >On Windows I use Notepad++ or Powershell for the general case (where
    >it's _not_ source code in an IDE).


    For source code IntelliJ has Java regexes built into the IDE is a
    quite convenient way. The problem mostly is scanning content for the
    website which is mostly HTML or embedded macros to do bulk changes.

    For this I need something quite quick with the ability to handle
    multiple files and multiple regexes per pass.

    I will have a look for PowerShell.

    If I write my own, I will build in a regex proofreader than lets you
    see by colour which chars are being taken literally and which as
    commands. It could also make sure () [] balance etc.

    It has also dawned on me that XML is a quite reasonable language to
    define scripts. You can create it with a gui. You can play with in
    with XML tools safely. You can edit it externally. It already has a
    mechanisms for comments, handling awkward characters and treating
    multiple spaces as significant. It is easy for others to generate
    with custom apps since they can avoid dealing with some of the messy
    details.

    --
    Roedy Green Canadian Mind Products
    http://mindprod.com
    I can't come to bed just yet. Somebody is wrong on the Internet.
    Roedy Green, Nov 25, 2011
    #3
  4. Roedy Green

    Arne Vajhøj Guest

    On 11/25/2011 3:17 AM, Roedy Green wrote:
    > I have been using Funduc Search/Replace with works command line, as a
    > gui, and with scripts to do multiple search-replaces on multiple
    > files.
    >
    > It work fine, except it uses a proprietary regex quite different from
    > Java Regex. I would like something just like it, but that use Java
    > Regex. I have unsuccessfully tried to talk the authors into supporting
    > Java syntax.
    >
    > see http://mindprod.com/jgloss/searchreplace.html
    > to see what I mean.
    >
    > I have not found anything suitable is a short google search. On my
    > todo list is to write one. What do you use?


    If you write something in Java, then you will get Java syntax.

    But Java is not special - Java uses standard Perl syntax - and
    I would expect there to be utilities that use Perl syntax.

    Otherwise then maybe write one in Perl! :)

    Arne
    Arne Vajhøj, Nov 25, 2011
    #4
  5. Roedy Green

    Daniel Pitts Guest

    On 11/25/11 1:46 PM, Roedy Green wrote:
    > On Fri, 25 Nov 2011 07:24:00 -0400, Arved Sandstrom
    > <> wrote, quoted or indirectly quoted
    > someone who said :
    >
    >>
    >> On Windows I use Notepad++ or Powershell for the general case (where
    >> it's _not_ source code in an IDE).

    >
    > For source code IntelliJ has Java regexes built into the IDE is a
    > quite convenient way. The problem mostly is scanning content for the
    > website which is mostly HTML or embedded macros to do bulk changes.

    IntelliJ has quite a nice HTML/XML editor as well, and its regex support
    works on those file types without any stretched imagination.
    >
    > For this I need something quite quick with the ability to handle
    > multiple files and multiple regexes per pass.

    Are you talking about from a command line? I tend to use "sed" for such
    tasks, but does not have Java syntax either. Not sure why you would
    force it too.
    >
    > I will have a look for PowerShell.
    >
    > If I write my own, I will build in a regex proofreader than lets you
    > see by colour which chars are being taken literally and which as
    > commands. It could also make sure () [] balance etc.

    The latest IntelliJ has a very nice regex editor.

    >
    > It has also dawned on me that XML is a quite reasonable language to
    > define scripts. You can create it with a gui. You can play with in
    > with XML tools safely. You can edit it externally. It already has a
    > mechanisms for comments, handling awkward characters and treating
    > multiple spaces as significant. It is easy for others to generate
    > with custom apps since they can avoid dealing with some of the messy
    > details.


    XML is quite a reasonable syntax for expressing trees. That doesn't make
    it a "good" language to define scripts.
    (a) It's not a language, but a markup syntax.
    (b) It's often too verbose for "scripts".
    (c) While it may seem nice to play/edit/inspect with existing tools,
    creating a tool which reads XML and performs commands is a bit
    of work. Surprisingly not much less complicated than a real
    compiler/interpreter.
    (d) ant does exactly what I'm saying isn't a good idea ;-)


    --
    Daniel.
    Daniel Pitts, Nov 26, 2011
    #5
  6. Roedy Green

    JussiJ Guest

    On Nov 26, 9:09 am, Arne Vajhøj <> wrote:

    > But Java is not special - Java uses standard Perl syntax - and
    > I would expect there to be utilities that use Perl syntax.


    FWIW the Zeus for Windows IDE has support for Java and it
    also has Perl syntax search and replace:

    http://www.zeusedit.com
    JussiJ, Dec 13, 2011
    #6
  7. Roedy Green

    Lew Guest

    JussiJ wrote:
    > Arne Vajhøj wrote:
    >> But Java is not special - Java uses standard Perl syntax - and
    >> I would expect there to be utilities that use Perl syntax.

    >
    > FWIW the Zeus for Windows IDE has support for Java and it
    > also has Perl syntax search and replace:


    The question of whether an IDE supports "Perl syntax search and replace" does not impinge on the target language's regular-expression capabilities.

    --
    Lew
    Lew, Dec 13, 2011
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mark McKay
    Replies:
    3
    Views:
    1,309
    Thomas Weidenfeller
    Jan 21, 2004
  2. Replies:
    3
    Views:
    350
  3. Martin Evans

    RegEx conditional search and replace

    Martin Evans, Jul 5, 2006, in forum: Python
    Replies:
    6
    Views:
    556
    Blair P. Houghton
    Jul 6, 2006
  4. Gilles Ganault

    [Regex] Search and replace?

    Gilles Ganault, Nov 13, 2008, in forum: Python
    Replies:
    1
    Views:
    247
    Sion Arrowsmith
    Nov 13, 2008
  5. David Pratt

    mmap regex search replace

    David Pratt, Apr 3, 2009, in forum: Python
    Replies:
    0
    Views:
    361
    David Pratt
    Apr 3, 2009
Loading...

Share This Page