Questions tagged [word-boundaries]
34 questions
130
votes
5 answers
Do regular expressions from the re module support word boundaries (\b)?
While trying to learn a little more about regular expressions, a tutorial suggested that you can use the \b to match a word boundary. However, the following snippet in the Python interpreter does not work as expected:
>>> x = 'one two three'
>>> y =…

D.C.
- 15,340
- 19
- 71
- 102
40
votes
2 answers
What are non-word boundary in regex (\B), compared to word-boundary?
What are non-word boundary in regex (\B), compared to word-boundary?

DarkLightA
- 14,980
- 18
- 49
- 57
13
votes
4 answers
List items run outside of list and div area
I'm having an issue with a menu un-ordered list. Whereby the list items are over running the
- and
- 4,676
- 19
- 80
- 155
boundaries and only starting the next line once it has reach the edge of the screen.
Heres the website:…

crmepham
10
votes
1 answer
Regular expression to match boundary between different Unicode scripts
Regular expression engines have a concept of "zero width" matches, some of which are useful for finding edges of words:
\b - present in most engines to match any boundary between word and non-word characters
\< and \> - present in Vim to match only…

hippietrail
- 15,848
- 18
- 99
- 158
9
votes
4 answers
preg_match for multiple words
I want to test a string to see it contains certain words.
i.e:
$string = "The rain in spain is certain as the dry on the plain is over and it is not clear";
preg_match('`\brain\b`',$string);
But that method only matches one word. How do I check for…

Asim Zaidi
- 27,016
- 49
- 132
- 221
6
votes
3 answers
word boundaries in irb
I'm using Terminal on Snow Leopard.
At the command line, if I've typed foo.bar.baz.bang.quuz.quux, when i tap option-B, it moves the cursor backward word by word -- stopping at every period, because it considers a period to be a word boundary.…

Lawrence
- 10,142
- 5
- 39
- 51
5
votes
5 answers
Word boundaries not matching when the word starts or ends with special character like square brackets
I want to replace string which is a square bracket with another number. I am using regex replace method.
Sample input:
This is [test] version.
Required output (replacing "[test]" with 1.0):
This is 1.0 version.
Right now regex is not replacing…
user11763179
5
votes
2 answers
Regex matching on word boundary OR non-digit
I'm trying to use a Regex pattern (in Java) to find a sequence of 3 digits and only 3 digits in a row. 4 digits doesn't match, 2 digits doesn't match.
The obvious pattern to me was:
"\b(\d{3})\b"
That matches against many source string cases, such…

Michael Oryl
- 20,856
- 14
- 77
- 117
5
votes
1 answer
Are there JavaScript equivalents of the Vim regular expression start and end of word atoms "\<" and "\>"?
I know most regular expression engines, including the one in JavaScript have \b to match a word boundary, be it at either the start or end of a word.
But Vim also has two more specific regular expression atoms:
\< matches only the word boundary at…

hippietrail
- 15,848
- 18
- 99
- 158
3
votes
1 answer
Non-capturing group matching whitespace boundaries in JavaScript regex
I have this function that finds whole words and should replace them. It identifies spaces but should not replace them, ie, not capture them.
function asd (sentence, word) {
str = sentence.replace(new RegExp('(?:^|\\s)' + word + '(?:$|\\s)'),…

N.Car
- 492
- 1
- 4
- 14
3
votes
3 answers
Matching WORD pattern through regex
Assume i have a big paragraph, in which there are words are like found field failed fired killed (so many negative words i know!!)
Now, I want to fetch line which have words starting from fi hi or k and ends with eld or ed
How would i go about…

NoobEditor
- 15,563
- 19
- 81
- 112
2
votes
3 answers
Match all space-delimited "words" containing at least 1 letter and 1 number and may contain slashes and hyphens
I have the following string:
SEDCVBNT S800BG09 7GFHFGD6H 324235346 RHGF7U S8-00BG/09 7687678
and the following regex:
preg_match_all('/\b(?=.+[0-9])(?=.+[A-Z])[A-Z0-9-\/]{4,20}/i', $string, $matches)
What I'm trying to achieve is to return all of…

Dave
- 63
- 1
- 4
2
votes
2 answers
Audio mining for words boundaries
What I plan on doing:
I want to develop the English accent (without professional training).
Set of axioms behind my reasoning with executive summary:
Following is knowingly over simplified, sorry for that. I tried to keep question short.
Part 1 :…

Margus
- 19,694
- 14
- 55
- 103
2
votes
4 answers
stop words removal using arrays c#
I have a string array of stopWords and string array of input texts i.e.
string[] stopWords = File.ReadAllLines(@"C:\stopWords.txt");
and
con.Open();
SqlCommand query = con.CreateCommand();
query.CommandText = "select p_abstract from aminer_paper…

maliks
- 1,102
- 3
- 18
- 42
2
votes
2 answers
Alignment of C structure
I have some binary data in a file and load the file into memory at char* data. Now I know e.g. that at offset 123 begins a struct something.
Is it safe to do the following
(struct something*) (data + 123) // ??&data [123]??
and then access members…

Hyperboreus
- 31,997
- 9
- 47
- 87