Comrade:CriticalResist/sandbox: Difference between revisions

No edit summary
Tag: Visual edit
No edit summary
Tag: Visual edit
Line 23: Line 23:
|-
|-
|<code>\s-{1,2}</code>
|<code>\s-{1,2}</code>
|detects a hyphen after a space
|Detects a hyphen or two after a space
|This can indicate incorrect use of an em dash —
|This can indicate incorrect use of an em dash —
Will detect either - or --, which are sometimes incorrectly used. Replace all with em dash ('''with a space before!)''' (but not ''after'')
Will detect either - or --, which are sometimes incorrectly used. Replace all with em dash ('''with a space before''' but not after)
|-
|<code>(?<!\s)\d+\s*[.\-\)]</code>
|Detects improperly formatted ordered lists (e.g. 1), 2), etc)
|We should use mediawiki lists instead of plain text. This detects such a case. Use only to find it, then apply the list format manually.
|}
|}

Revision as of 16:06, 8 July 2023

Some useful regex functions

You can use search and replace with regex in the visual editor, just tap Ctrl+f on your keyboard, then click on the icon representing (.*) — that's the regex (regular expression) function, which will interpret your search string as regex.

Unfortunately you can't use regex in the replace function but anyway, here are some cool regex functions you can use to help you on pages. Just copy the "regex code" row into the search bar (yes it looks like nothing, that's normal)

Regex code What it does Use for
\[(\d+)\] Detects references like [12] Transform plain text references into formatted MediaWiki references (ctrl+shift+k to add a reference)
\s{2,} Detect two spaces or more Search for this code then press replace all and it will correct all possible extra spaces.
\s(?=[.,;:!?'")%]) Remove space before punctuation Removes a space before punctuation, like . or ? or ;

be careful before replacing all, you should look through instances one by one.

\s-{1,2} Detects a hyphen or two after a space This can indicate incorrect use of an em dash —

Will detect either - or --, which are sometimes incorrectly used. Replace all with em dash (with a space before but not after)

(?<!\s)\d+\s*[.\-\)] Detects improperly formatted ordered lists (e.g. 1), 2), etc) We should use mediawiki lists instead of plain text. This detects such a case. Use only to find it, then apply the list format manually.