Gedit regular expressions plugin: Difference between revisions

From WickyWiki
Line 14: Line 14:
== Examples ==
== Examples ==


=== Replace trailing whitespaces and /r with /n ===
=== Replace trailing white-spaces and /r with /n ===


Search:  
Search:  
Line 38: Line 38:


Search:
Search:
  '[0-9]{2,3}\n{2,3}'
  [0-9]{2,3}\n{2,3}


=== Remove '-' in words ===
=== Remove '-' in words ===

Revision as of 18:21, 16 November 2011

Install

  1. download the plugin from http://halfhourhacks.blogspot.com/2008/03/gedit-regular-expression-plugin.html
  2. extract the contents to ~/.gnome2/gedit/plugins/ you will have these files:
    • ~/.gnome2/gedit/plugins/regex_replace.gedit-plugin
    • ~/.gnome2/gedit/plugins/regex_replace.gedit-plugin/regex_replace
  3. restart gedit
  4. in the menu: Edit -> Preferences -> plugins -> enable Expression Replace
  5. now you should have a "Regular Expression" item in the Search menu.

Other gedit plugins

Examples

Replace trailing white-spaces and /r with /n

Search:

[ \t\r\n]{1,9}

Replace with:

\n

Split word with capital letter in the middle

Search:

([a-z,.])([A-Z])

Replace with:

\1 \2

Search 1 (one) in a non-number

Search:

[^0-9]1[^0-9]

Search number > 9

Search:

[0-9]{2,3}\n{2,3}

Remove '-' in words

Search:

([a-z])-\n{1,9}([a-z])

Replace with:

\1\2

Remove EOL: trailing and leading non-capital letter

Search:

([a-z,;:])[ \n]{1,9}([a-z])

Replace with:

\1 \2

Remove EOL: leading non-capital letter

Search:

\n{1,9}([a-z])

Replace with ('_' should be a space):

_\1

Remove EOL: trailing non-capital letter

Search:

([a-z,;:])\n{1,9}

Replace with ('_' should be a space):

\1_

Regular expressions in Office Libre

You can also use regular expressions in Office Libre.

Remove paragraph trailing space

Search:

'^(.*) $'

Replace with:

'$1'