This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
A word boundary `pattern:\b` is a test, just like `pattern:^` and `pattern:$`.
Il confine di parola `pattern:\b` è un test, proprio come `pattern:^` e `pattern:$`.
When the regexp engine (program module that implements searching for regexps) comes across `pattern:\b`, it checks that the position in the string is a word boundary.
Quando l'interprete delle regexp (il modulo software che cerca all'interno delle espressioni regolari) incontra `pattern:\b`, verifica se la posizione nella stringa sia un confine di parola.
There are three different positions that qualify as word boundaries:
Ci sono tre differenti posizioni che qualificano il confine di parola:
- At string start, if the first string character is a word character `pattern:\w`.
- Between two characters in the string, where one is a word character `pattern:\w` and the other is not.
- At string end, if the last string character is a word character `pattern:\w`.
- Ad inizio stringa, se il primo carattere di essa è un carattere di parola `pattern:\w`.
- Tra due caratteri di una stringa, laddove il primo sia un carattere di parola `pattern:\w` e l'altro no.
- A fine stringa, se l'ultimo carattere è un carattere di parola `pattern:\w`.
For instance, regexp `pattern:\bJava\b` will be found in `subject:Hello, Java!`, where `subject:Java` is a standalone word, but not in `subject:Hello, JavaScript!`.
Ad esempio, la regexp `pattern:\bJava\b` troverà corrispondenza in `subject:Hello, Java!`, dove `subject:Java` è una parola a sé, ma non troverà alcuna corrispondenza in `subject:Hello, JavaScript!`.
In the string `subject:Hello, Java!` following positions correspond to `pattern:\b`:
Nella stringa `subject:Hello, Java!` trovano riscontro in `pattern:\b` le seguenti posizioni:

So, it matches the pattern `pattern:\bHello\b`, because:
Pertanto la corrispondenza con il pattern `pattern:\bHello\b` viene trovata perché:
1. At the beginning of the string matches the first test `pattern:\b`.
2. Then matches the word `pattern:Hello`.
3. Then the test `pattern:\b` matches again, as we're between `subject:o` and a comma.
1. All'inizio della stringa trova riscontro con il primo test `pattern:\b`.
2. Successivamente identifica la parola `pattern:Hello`.
3. Infine trova ancora corrispondenza con il test `pattern:\b`, dal momento che la posizione corrente è tra una `subject:o` e una virgola.
So the pattern `pattern:\bHello\b` would match, but not `pattern:\bHell\b` (because there's no word boundary after `l`) and not `Java!\b` (because the exclamation sign is not a wordly character `pattern:\w`, so there's no word boundary after it).
Viene quindi individuato il pattern `pattern:\bHello\b`, ma non `pattern:\bHell\b` (perché non c'è un confine di parola dopo la `l`) e non `Java!\b` (perché il punto esclamativo non è un carattere di parola `pattern:\w`, quindi non c'è confine di parola dopo di esso).
We can use `pattern:\b` not only with words, but with digits as well.
Possiamo usare `pattern:\b` anche con i numeri non solo con le parole.
For example, the pattern `pattern:\b\d\d\b` looks for standalone 2-digit numbers. In other words, it looks for 2-digit numbers that are surrounded by characters different from `pattern:\w`, such as spaces or punctuation (or text start/end).
Il pattern `pattern:\b\d\d\b`, ad esempio, cerca due caratteri numerici a sé stanti. In altre parole, cerca un numero di due cifre delimitato da caratteri differenti da `pattern:\w`, come spazi o punteggiatura (o l'inizio/la fine della stringa).
```warn header="Word boundary `pattern:\b` doesn't work for non-latin alphabets"
The word boundary test `pattern:\b` checks that there should be `pattern:\w` on the one side from the position and "not `pattern:\w`" - on the other side.
```warn header="Il confine di parola `pattern:\b` funziona solo con l'alfabeto latino"
Il test di confine parola `pattern:\b` controlla che ci sia `pattern:\w` da un lato della posizione e che non ci sia `pattern:\w` dall'altro lato.
But `pattern:\w` means a latin letter `a-z` (or a digit or an underscore), so the test doesn't work for other characters, e.g. cyrillic letters or hieroglyphs.
Ma `pattern:\w` significa una lettera dell'alfabeto latino `a-z` (o un numero o un underscore), pertanto il test non è efficace per altri caratteri, es. caratteri cirillici o simboli grafici.
```
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Word boundary: \b #293
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Word boundary: \b #293
Filter by extension
Viewed files
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There are no files selected for viewing