You are not logged in.
Pages: 1
I need to find a regular expression that matches words with three characters (and the first letter is upper). I don't know enough about regular expression for doing it myself. How can I do?
Offline
take a look on google, this is a pretty basic regex.
http://www.regular-expressions.info/tutorial.html
http://www.amk.ca/python/howto/regex/
http://www.codeproject.com/KB/dotnet/regextutorial.aspx
that should be more than enough to get you started.
also, what language are you trying to make a regular expression for? the syntax can be different from language to language.
Last edited by Cyrusm (2010-04-25 13:05:50)
Hofstadter's Law:
It always takes longer than you expect, even when you take into account Hofstadter's Law.
Offline
Take a look at
http://www.grymoire.com/Unix/Regular.html#uh-9
and
http://www.grymoire.com/Unix/Regular.html#uh-13
and
http://www.grymoire.com/Unix/Regular.html#uh-8
echo 'you You Your' | sed 's/\<[[:upper:]][[:alpha:]]\{2\}\>/XXX/g'
you XXX Your
Offline
also, what language are you trying to make a regular expression for? the syntax can be different from language to language.
for Python and grep
Thanks to all for replies.
EDIT: I've found this:
grep '\<[A-Za-z]\{3\}\>'
But it matches both capital and lower case. However, it's a good beginning point. :-)
Last edited by fgr (2010-04-25 14:00:30)
Offline
Cyrusm wrote:also, what language are you trying to make a regular expression for? the syntax can be different from language to language.
for Python and grep
Thanks to all for replies.
EDIT: I've found this:
grep '\<[A-Za-z]\{3\}\>'
But it matches both capital and lower case. However, it's a good beginning point. :-)
try :
grep '\<[A-Z][a-z]\{2\}\>'
It will find all words of three letters, beginning with an uppercase character, and finishing with two lowercase characters.
Offline
Cyrusm wrote:also, what language are you trying to make a regular expression for? the syntax can be different from language to language.
for Python and grep
When I first saw Cyrusm's post, I thought he meant natural languages. I thought that an interesting point I had never considered. Almost every language I ever encounter is based on the Latin alphabet (or simple variations on it). I realized I had no concept of how to deal with Greek, Syrillic, Arabic, Korean, and Various Japanese and Chinese alphabets.
Then I saw fgr's response as to programming language's, at which point I wondered if I had missed the point.
Without intending to hijack the thread, How do RE's work for languages that read right to left, or that may be more symbolic in nature?
Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way
Offline
[...]
try :grep '\<[A-Z][a-z]\{2\}\>'
It will find all words of three letters, beginning with an uppercase character, and finishing with two lowercase characters.
it works fine, thanks.
Offline
fgr wrote:Cyrusm wrote:also, what language are you trying to make a regular expression for? the syntax can be different from language to language.
for Python and grep
When I first saw Cyrusm's post, I thought he meant natural languages. I thought that an interesting point I had never considered. Almost every language I ever encounter is based on the Latin alphabet (or simple variations on it). I realized I had no concept of how to deal with Greek, Syrillic, Arabic, Korean, and Various Japanese and Chinese alphabets.
Then I saw fgr's response as to programming language's, at which point I wondered if I had missed the point.
Without intending to hijack the thread, How do RE's work for languages that read right to left, or that may be more symbolic in nature?
hm. I never thought of it that way. it might be something worth researching...
Hofstadter's Law:
It always takes longer than you expect, even when you take into account Hofstadter's Law.
Offline
fgr wrote:Cyrusm wrote:also, what language are you trying to make a regular expression for? the syntax can be different from language to language.
for Python and grep
When I first saw Cyrusm's post, I thought he meant natural languages. I thought that an interesting point I had never considered. Almost every language I ever encounter is based on the Latin alphabet (or simple variations on it). I realized I had no concept of how to deal with Greek, Syrillic, Arabic, Korean, and Various Japanese and Chinese alphabets.
[...]
It's an interesting matter. But, we don't forget who makes international standards for any area of applicability is a western institution...
Last edited by fgr (2010-04-27 17:12:36)
Offline
Pages: 1