Gedit regular expressions plugin: Difference between revisions

From WickyWiki
Line 16: Line 16:
Note: use the example strings without the quotes.
Note: use the example strings without the quotes.


=== Replace trailing whitespaces and /r by /n ===
=== Replace trailing whitespaces and /r with /n ===


Search:  
Search:  

Revision as of 18:15, 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

Note: use the example strings without the quotes.

Replace trailing whitespaces and /r with /n

Search:

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

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:

' \1'

Remove EOL: trailing non-capital letter

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

Regular expressions in Office Libre

You can also use regular expressions in Office Libre.

Remove paragraph trailing space

Search:

'^(.*) $'

Replace with:

'$1'