Gedit regular expressions plugin: Difference between revisions
From WickyWiki
| Line 13: | Line 13: | ||
== Examples == | == Examples == | ||
Note: were needed an underscore (_) is used to denote a space. | |||
=== Replace trailing white-spaces and /r with /n === | === Replace trailing white-spaces and /r with /n === | ||
Search | {|style="color:navy; background-color:#ffffcc;" cellpadding="5" cellspacing="0" border="1" | ||
|- | |||
! Search | |||
! Replace with | |||
|- | |||
| [ \t\r\n]{1,9} | |||
| \n | |||
|} | |||
=== Split word with capital letter in the middle === | === Split word with capital letter in the middle === | ||
Search | {|style="color:navy; background-color:#ffffcc;" cellpadding="5" cellspacing="0" border="1" | ||
|- | |||
! Search | |||
! Replace with | |||
|- | |||
| ([a-z,.])([A-Z]) | |||
| \1 \2 | |||
|} | |||
=== | === Replace 1 (one) in a non-number with I === | ||
Search | {|style="color:navy; background-color:#ffffcc;" cellpadding="5" cellspacing="0" border="1" | ||
|- | |||
! Search | |||
! Replace with | |||
|- | |||
| [^0-9]1[^0-9] | |||
| I | |||
|} | |||
=== Search number > 9 === | === Search number > 9 === | ||
Search | {|style="color:navy; background-color:#ffffcc;" cellpadding="5" cellspacing="0" border="1" | ||
|- | |||
! Search | |||
|- | |||
| [0-9]{2,9} | |||
|} | |||
=== Remove '-' in words === | === Remove '-' in words === | ||
Search | {|style="color:navy; background-color:#ffffcc;" cellpadding="5" cellspacing="0" border="1" | ||
|- | |||
! Search | |||
! Replace with | |||
|- | |||
| ([a-z])-\n{1,9}([a-z]) | |||
| \1\2 | |||
|} | |||
=== Remove EOL: trailing and leading non-capital letter === | === Remove EOL: trailing and leading non-capital letter === | ||
Search | {|style="color:navy; background-color:#ffffcc;" cellpadding="5" cellspacing="0" border="1" | ||
|- | |||
! Search | |||
! Replace with | |||
|- | |||
| ([a-z,;:])[ \n]{1,9}([a-z]) | |||
| \1 \2 | |||
|} | |||
=== Remove EOL: leading non-capital letter === | === Remove EOL: leading non-capital letter === | ||
Search | {|style="color:navy; background-color:#ffffcc;" cellpadding="5" cellspacing="0" border="1" | ||
|- | |||
! Search | |||
! Replace with | |||
|- | |||
| \n{1,9}([a-z]) | |||
| _\1 | |||
|} | |||
=== Remove EOL: trailing non-capital letter=== | === Remove EOL: trailing non-capital letter=== | ||
Search | {|style="color:navy; background-color:#ffffcc;" cellpadding="5" cellspacing="0" border="1" | ||
|- | |||
! Search | |||
! Replace with | |||
|- | |||
| ([a-z,;:])\n{1,9} | |||
| \1_ | |||
|} | |||
== Regular expressions in Office Libre == | == Regular expressions in Office Libre == | ||
Revision as of 18:40, 16 November 2011
Install
- download the plugin from http://halfhourhacks.blogspot.com/2008/03/gedit-regular-expression-plugin.html
- 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
- restart gedit
- in the menu: Edit -> Preferences -> plugins -> enable Expression Replace
- now you should have a "Regular Expression" item in the Search menu.
Other gedit plugins
Examples
Note: were needed an underscore (_) is used to denote a space.
Replace trailing white-spaces and /r with /n
| Search | Replace with |
|---|---|
| [ \t\r\n]{1,9} | \n |
Split word with capital letter in the middle
| Search | Replace with |
|---|---|
| ([a-z,.])([A-Z]) | \1 \2 |
Replace 1 (one) in a non-number with I
| Search | Replace with |
|---|---|
| [^0-9]1[^0-9] | I |
Search number > 9
| Search |
|---|
| [0-9]{2,9} |
Remove '-' in words
| Search | Replace with |
|---|---|
| ([a-z])-\n{1,9}([a-z]) | \1\2 |
Remove EOL: trailing and leading non-capital letter
| Search | Replace with |
|---|---|
| ([a-z,;:])[ \n]{1,9}([a-z]) | \1 \2 |
Remove EOL: leading non-capital letter
| Search | Replace with |
|---|---|
| \n{1,9}([a-z]) | _\1 |
Remove EOL: trailing non-capital letter
| Search | Replace with |
|---|---|
| ([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