If you the regular expressions may appear jargon to define those dialogues were born to be said but to be heard, "Hey, how are you?" "There ' is bad, and you? ", perhaps you should reconsider your definition when you have a program that wipes out in front of his eyes while he says, sounding sullen, dull drivel that those are routine.
To make you understand the resentment of the programmer to you, think about the harmony you perceive when you can say "I have regular bowel " and now, after entering into this harmonious state, think of the feeling of seize power by ' expression interlocutor after telling him "I did the Stelvio pass in cycling," Well if you add up the two sensations you might have a vague idea of \u200b\u200bthe pathos that the programmer lives against and regular expressions of his hatred towards you because not participating in the same emotion and idolatry on such magnificence.
Already, the programmer when he hears the expression regular expressions and estasiaticamente inevitably sees before one's eyes the superlative power of strings also this:
'/^[^ 0-9] [a-zA-Z0-9_] + ( [.] [a-zA-Z0-9_ ]+)*[@][ a-zA-Z0-9_ ]+([.][ a-zA-Z0-9_-to ]+)*[.][ zA-Z] {2,4} $ / '
source
As you can see from the above-quoted string, the regular expression represent the most powerful and fastest way to do lexical analysis of a text.
If at this point you are still in the oblivion of that is to say?? evidentemente non avete minimamente colto l'opportunità di poter lavorare meno ...e meglio (ma quest'ultimo aspetto forse interessa a molti meno).
La fatica ai muli
Vi sarà sicuramente capitato di soffrire per un vostro collega, o per voi stessi, quando lo vedete ridotto a un mulo automa, ad esempio, mentre corregge manualmente la punteggiatura di un elenco con centinaia di voci.Non so a voi, ma a me capita spesso di dover correggere la punteggiatura errata dei punti elenco (ma io non soffro), già perché sovente gli autori dimenticano che un punto elenco dovrebbe avere un'adeguata punteggiatura: ogni voce termina con il punto e virgola tranne l'ultima che termina con il punto.
Un esempio per tutti
Moltissimi editor di testi offrono appunto l'utilizzo delle espressioni regolari, ad esempio se con Writer di OpenOffice dobbiamo provvedere a inserire la punteggiatura dimenticata (il punto e virgola alla fine della voce) in un mastodontico elenco, invece di chinare la testa e digitare a mo' di uomo robotizzato i punti e virgola per ogni voce per le prossime ore possiamo semplicemente e velocemente selezionare l'intero elenco, tranne l'ultima voce (dove metterete il punto), e dal menu Modifica scegliere il comando Cerca e sostituisci .
Nella finestra che comparirà dovrete cliccare sul pulsante in basso Other Options and put the check mark:
- only in the selection ;
- Regular expression.
Now, having enabled the regular expressions, you can pick the rules of lexical analysis.
In our case, in Search we will need to tell him to seek the end of each line, to do this simply type the character $ which indicates the end line.
Then in the Replace with field , we tell him to put the semicolon, but, importantly, we must also tell him not to remove the newline, so type the following combination Character:
\\ n
where ; is the character that will be inserted (replace) at each end of the line, and characters \\ n specify to keep (or replace) the end of the line in order to maintain the vertical structure list (otherwise we would end up all the items in a single horizontal line). And if ...
And if the author turns to rookie of the text had to be corrected manually entered the numbers in front of the item in the list, how to remove it to leave (or enter) only bullet formatting to the editor?
Simple: by using le espressioni regolari !
Compiendo le operazione poc'anzi menzionate, nel campo Cerca scriveremo:
^[:digit:].
Mentre il campo Sostituisci con lo lasceremo vuoto. Ehi, non dimenticarti infine di cliccare sul pulsante Sostituisci tutto !!
Take It Easy
Quando la pigrizia ti impedisce di leggerti l'help
Ti riporto la pagina di OpenOffice che spiega i caratteri usati per scrivere le espressioni regolari in Writer (ma impara a leggerti gli help):| Carattere | Effect / use |
| Any character represents the character data unless otherwise noted. | |
| .. | Represents any single character except the characters a line break or paragraph break. For example, search for "R.ssi" returns both "Smith" and "Russians." |
| ^ | Find the search term appears only at the beginning of a paragraph. Any special items (such as empty fields or character anchored frames) at the beginning of a paragraph are ignored. Example: "^ Mario." |
| $ | Find the word sought if it appears at the end of a paragraph. Any special items (such as empty fields or character anchored frames) at the end of a paragraph are ignored. Example: "Mario $". |
| * Identifies the absence or presence of one or more of the characters preceding "*". For example, "Ab * c" finds "Ac", "Abc", "ABBC", "abbbc" and so on. | |
| + | Identifies one or more characters before "+". For example, "AX. +4" Finds "AXx4" but not "AX4". will always find the longest string corresponding to the search pattern in a paragraph. If the paragraph contains the string "AX 4 AX4" the entire passage is highlighted. |
| ? | Finds zero or a single occurrence of the characters before "?". For example, "Texts?" return "Test" and "Text", and "x (ab the key combination Shift + Enter. To transform the line break in a paragraph break, enter | \\ n
| Search and Replace with | , then execute a search and replace. | \\ n in the text box
| \\ n in the Replace With text box | is a paragraph that can be inserted with the Enter key. \\ t Represents a tab. You can use this expression in the Replace with box . \\> |
| \\ \u0026lt; Find the search term appears only at the beginning of a word. For example, "\\ \u0026lt;love" finds "friends" but not "branches". | |
| ^ $ | Locate an empty paragraph. |
| ^. Search | the first character of a paragraph. |
| & o $ 0 | When you make a replacement, adds the string found by the search criteria in the Search box |
| . | Ad esempio, se inserite "cornice" nella casellaCerca | e "&finestra" nella casella
| Immettendo il carattere "&" nella casella | Sostituisci con potete modificare gli Attributi o il Formato della stringa individuata dai criteri di ricerca. [abc123] Rappresenta uno dei caratteri compresi tra parentesi. [a-e] Rappresenta i caratteri compresi tra le lettere "a" ed "e". |
| [a-eh-x] | represents the characters between the letters "a" and "e" and between the letters "h" and "x". |
| [^ as] | represents the characters between "a" and "s". |
| \\ XXXXX | represents a special character by its hexadecimal code to four digits (XXXX). | The code for the special character depends on the font used. To view the codes, choose
| this trova sia "questo" che "quello". | |
| {2} | Definisce il numero di ripetizioni del carattere che precede la parentesi graffa aperta. Ad esempio, "mol{2}e" trova "molle". |
| Definisce quante volte può ripetersi il carattere che precede la parentesi graffa aperta. Ad esempio, "mol{1,2}e" trova "mole" e "molle". | |
| Definisce il numero minimo di volte che il carattere che precede la parentesi graffa aperta può ripetersi. Ad esempio, "mol{2}e" trova "molle", "mollle" e "mollllle". | |
| Nella casella Search | : | Defines the characters in brackets for reference. You can then refer to the first referenced in the active with "\\ 1" per second "\\ 2" and so on.
| : | Use the $ (dollar) instead of \\ (double backslash) to replace references. $ 0 used to replace the entire string found.|
| [:alpha:] | Rappresenta un carattere alfabetico. Per cercarne uno usate [:alpha:]+. [:digit:] Rappresenta una cifra decimale. Per cercarne una usate [:digit:]+. |
| Rappresenta un carattere alfanumerico ([:alpha:] e [:digit:]). | |
| Rappresenta un carattere di spazio singolo (ma non altri caratteri di spaziatura). | |
| Rappresenta qualsiasi carattere stampabile. | |
| Rappresenta qualsiasi carattere non stampabile. | |
| represents a lowercase character if you selected | Search Optionsexact |
| [: upper:] | |
| exact | area. |
0 comments:
Post a Comment