Is it possible to use a regular expression to find such a construction in the text:
SPACE+"."+any character+"."
Searching for a string in the text
- Antonio Linares
- Site Admin
- Posts: 42268
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Searching for a string in the text
Yes, it's possible to use a regular expression to find the construction you described: SPACE + "." + any character + "."
Here's a regular expression that would match this pattern:
Let me break down this regex for you:
1. `\s+`: This matches one or more whitespace characters (including spaces, tabs, and newlines).
2. `\.`: This matches a literal dot (period). The backslash is used to escape the dot, as a dot normally has a special meaning in regex.
3. `\w`: This matches any word character (letters, digits, or underscore).
4. `\.`: Another literal dot.
This regex will find patterns like " .a.", " .B.", " .9.", etc. in your text.
Here's a regular expression that would match this pattern:
Code: Select all | Expand
\s+\.\w\.
1. `\s+`: This matches one or more whitespace characters (including spaces, tabs, and newlines).
2. `\.`: This matches a literal dot (period). The backslash is used to escape the dot, as a dot normally has a special meaning in regex.
3. `\w`: This matches any word character (letters, digits, or underscore).
4. `\.`: Another literal dot.
This regex will find patterns like " .a.", " .B.", " .9.", etc. in your text.
Re: Searching for a string in the text
I understood you correctly ?
HB_ATX([s][.][w][.])
HB_ATX([s][.][w][.])
- Antonio Linares
- Site Admin
- Posts: 42268
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Searching for a string in the text
LOCAL pCompiled := hb_regexComp( "\s+\.\w\." )
LOCAL aMatch
LOCAL lRet := .t.
aMatch = hb_regex( pCompiled, alltrim(cText) )
if Empty( aMatch )
lRet := .f.
end
return lRet
LOCAL aMatch
LOCAL lRet := .t.
aMatch = hb_regex( pCompiled, alltrim(cText) )
if Empty( aMatch )
lRet := .f.
end
return lRet
Re: Searching for a string in the text
it doesn't work
pCompiled := hb_regexComp( "\s\w\.\w\." ) -->***
hb_regex( pCompiled, alltrim(cText) ) --> empty
maybe it's just for the Latin alphabet ?
pCompiled := hb_regexComp( "\s\w\.\w\." ) -->***
hb_regex( pCompiled, alltrim(cText) ) --> empty
maybe it's just for the Latin alphabet ?
Re: Searching for a string in the text
That's how it works:
Code: Select all | Expand
cReg:="\s[А-я][.][А-я][.]"
res:=HB_ATX(cReg, cText)
if ! empty(res)
.................
endif
- Antonio Linares
- Site Admin
- Posts: 42268
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact: