Both sides previous revision
Previous revision
Next revision
|
Previous revision
Next revision
Both sides next revision
|
public:nnels:etext:regex [2018/07/12 17:07] leah.brochu |
public:nnels:etext:regex [2024/05/29 18:49] rachel.osolen |
* If you wanted to remove the hyphen from "BB-8" you would enter ''\1\2'' (i.e., the two groups with nothing between them) into the Replace field. Or, if you wanted to change the hyphen to a space, you would enter ''\1 \2'' (i.e., the two groups with a space between them) into the Replace field. | * If you wanted to remove the hyphen from "BB-8" you would enter ''\1\2'' (i.e., the two groups with nothing between them) into the Replace field. Or, if you wanted to change the hyphen to a space, you would enter ''\1 \2'' (i.e., the two groups with a space between them) into the Replace field. |
* Another example: ''(John) (Smith)'' replaced by ''\2 \1'' (note the spaces in the search and replace strings) – will produce ''Smith John'' | * Another example: ''(John) (Smith)'' replaced by ''\2 \1'' (note the spaces in the search and replace strings) – will produce ''Smith John'' |
| |
| <note tip>Word has a lot of options to find letters (^$) and numbers (^#) when using the non-regex [[public:nnels:etext:find-and-replace|Find & Replace]], but these only work with the wildcard option //off// (which it is by default). Only turn the wildcard option on if you're using regex options. Read the info page carefully on when things apply with the wildcard option on/off. |
| </note> |
| |
====Tips==== | <note tip>A lot of the codes for special characters (e.g. page break) are under the "Special..." button. |
| </note> |
[[https://support.office.com/en-ca/article/Find-and-replace-text-and-other-data-in-your-Word-2010-files-c6728c16-469e-43cd-afe4-7708c6c779b7?ui=en-US&rs=en-CA&ad=CA#__toc282774574|Using wildcards in Microsoft Word]] (this is similar to regular expressions, but Word has a lot of its own syntax) | |
| |
* Word has a lot of options to find letters (^$) and numbers (^#) when using the non-regex [[public:nnels:etext:find-and-replace|Find & Replace]], but these only work with the wildcard option //off// (which it is by default). Only turn the wildcard option on if you're using regex options. Read the info page carefully on when things apply with the wildcard option on/off. | |
| |
* A lot of the codes for special characters (e.g. page break) are under the "Special..." button. | =====Problems and Solutions Using Regular Expressions===== |
{{:public:nnels:regex.png?400|}} | |
==== In LibreOffice & OpenOffice ==== | |
Make sure that the ''Regular expressions'' box is checked on the Alternative Find & Replace dialog for all of the search and replace actions below. | |
| |
[[https://help.libreoffice.org/Common/List_of_Regular_Expressions|Regular expressions in LibreOffice]] | In this section you will find examples of different ways to use ''Find and Replace'' to help you with some common reformatting issues. |
[[https://wiki.openoffice.org/wiki/Documentation/How_Tos/Regular_Expressions_in_Writer|Regular Expressions in OpenOffice]] | |
| |
===== Conversion Fixes ===== | <note tip>If you don't see the solution to your problem on this page, go to the [[public:nnels:etext:find-and-replace|Using Find & Replace]]. If you still can't find it, they try writing your own Regex, or using a wild card for find and replace.</note> |
The following fixes assume you are using Word, unless otherwise stated. | |
| |
<note>Contribute your problems and regex solutions below. Attach your screenshots of both the problem and solution.</note> | <note>If you discover a solution to a problem that is not on this page, please contact the Production Coordinator. They can teach you how to add your own solutions through updating this wiki page!</note> |
| |
---- | ---- |
| |
Find: ''([a-z])-^13([a-z])'' | Find: ''([a-z])-^13([a-z])'' |
| |
| Replace with: ''\1\2'' |
| |
| Using a-z restricts what it finds to lowercase. |
| |
| You will likely have to do it again for lines that end with a comma, and possibly en and em dash. Look through your document for patterns of anything else it might have missed. |
| </WRAP> |
| |
| ---- |
| |
| <WRAP center round box 80%> |
| **PROBLEM**: Hyphenated words that break single word (not over two lines). |
| |
| **SOLUTION**: Replace with the same text minus the hyphen. |
| |
| Find: ''([a-z])-([a-z])'' |
| |
Replace with: ''\1\2'' | Replace with: ''\1\2'' |
| |
---- | ---- |
| |
| |
<WRAP center round box 80%> | <WRAP center round box 80%> |
* ''\p.+\s+[0-9OoIil]{1,3}\p'' ### Detect bad line breaks ### | * ''\p.+\s+[0-9OoIil]{1,3}\p'' ### Detect bad line breaks ### |
* ''[^\."?!]$'' | * ''[^\."?!]$'' |
| |
| |
| [[public:nnels:etext:start|Return to main eText Page]] |
| |