473,545 Members | 2,772 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

string.find for case insensitive search

Is there a good way how to use string.find function to find a
substring if I need to you case insensitive substring?
Thanks for reply
LL

Feb 7 '07 #1
11 51779
"Johny" <py****@hope.cz wrote:
Is there a good way how to use string.find function to find a
substring if I need to you case insensitive substring?
s.lower().find( substring.lower ())

Feb 7 '07 #2
lower() is also deprecated :) oh well

On 7 Feb 2007 21:06:08 GMT, Duncan Booth <du**********@i nvalid.invalidw rote:
"Johny" <py****@hope.cz wrote:
Is there a good way how to use string.find function to find a
substring if I need to you case insensitive substring?

s.lower().find( substring.lower ())

--
http://mail.python.org/mailman/listinfo/python-list
Feb 7 '07 #3
Johny a écrit :
Is there a good way how to use string.find function to find a
substring if I need to you case insensitive substring?
"abCdZEd".lower ().find("BcD".l ower())

Feb 7 '07 #4
Johny wrote:
Is there a good way how to use string.find function to find a
substring if I need to you case insensitive substring?
Thanks for reply
LL
Maybe something like:

x="my string I'm going to SEarCH"
hasword='SEARCH ' in x.upper()
location=x.uppe r().find('SEARC H')

print hasword
True

print location
23
-Larry

Feb 7 '07 #5
string.find is deprecated as per the official python documentation.

take a look at the "re" module

On 7 Feb 2007 12:53:36 -0800, Johny <py****@hope.cz wrote:
Is there a good way how to use string.find function to find a
substring if I need to you case insensitive substring?
Thanks for reply
LL

--
http://mail.python.org/mailman/listinfo/python-list
Feb 7 '07 #6
Don Morrison wrote:
lower() is also deprecated :) oh well
The string method .lower() is not deprecated.

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco

Feb 7 '07 #7
"Don Morrison" <do*********@gm ail.comwrote:
lower() is also deprecated :) oh well

On 7 Feb 2007 21:06:08 GMT, Duncan Booth
<du**********@i nvalid.invalidw rote:
>"Johny" <py****@hope.cz wrote:
Is there a good way how to use string.find function to find a
substring if I need to you case insensitive substring?

s.lower().find (substring.lowe r())
No. RTFM and don't top post.

The functions such as lower() and find() in the string *module* are
deprecated. The methods are what you should use.

Feb 7 '07 #8
My apologies, I confused the built-in "str" with the module "string".
I was reading from the section of the 2.4.4 docs called: 4.1.4
Deprecated string functions

On 2/7/07, Robert Kern <ro*********@gm ail.comwrote:
Don Morrison wrote:
lower() is also deprecated :) oh well

The string method .lower() is not deprecated.

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco

--
http://mail.python.org/mailman/listinfo/python-list
Feb 7 '07 #9
Don Morrison wrote:
string.find is deprecated as per the official python documentation.
but the str.find() method isn't.
take a look at the "re" module
A possibility.

regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
Blog of Note: http://holdenweb.blogspot.com
See you at PyCon? http://us.pycon.org/TX2007

Feb 7 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3145
by: ajay.sonawane | last post by:
How can I find the wheather the occurance substring is main string in wide char provided that the compasion should be case insensitive.
3
12205
by: Guoqi Zheng | last post by:
Sir, To my experience, the string.indexof function is case sensitive. I need it to be case insensitive, how should I achieve this? -- Kind regards Guoqi Zheng guoqi AT meetholland dot com
0
332
by: Dragan Matic | last post by:
Is there a way to set up collation order to be case-insensitive? I.E. I need to have a column c with value 'ABC' and when I do a "select * from table where c = 'abc'" it finds the row with value 'ABC'. Yes, I know that I can do it with "lower()" and "upper()" functions, but is there a way to construct a database to be case-insensitive? Tnx in...
2
2327
by: John | last post by:
Does anyone know how to how to performance case-insensitive search on XML data type in SQLServer 2005? Or I have to convert all the xml data to lower case before I store it? Thanks in advance. John
1
2157
by: ericswebber | last post by:
Case Insensitive Search with Sensitive Replace -------------------------------------------------------------------- Need a REGEX case insensitve search & replace where case of found string is mirrored in replacement string please. The above question is basically how does one perform a REGEX Case insensitve search and replace where the...
1
35405
by: iksando | last post by:
Hello, I'm looking for solution in case insensitive search in MySql. Table exemple. CREATE TABLE `pozycje` ( `id` int(11) NOT NULL auto_increment, `eid` varchar(20) collate latin2_bin default NULL, `poz_nazwa` varchar(40) collate latin2_bin NOT NULL,
4
8149
by: bb | last post by:
Hi, void fun(const std::map<std::string,int>& m1) { // How to make a case insensitive search of this map without making a copy? } cheers.
7
2425
by: Adrian | last post by:
Why does std::strings find search from the begining of the string when pos >= (std::string::npos-3) I cant find anything in the standard that says what find should do if pos==npos in find I tried it on a few platforms (all with gcc unfortunaley) and its seems to be consistent. Adrian
14
24246
by: Mosfet | last post by:
Hi, what is the most efficient way of doing a case insensitive comparison ? I am trying to write a universal String class and I am stuck with the case insensitive part : TCHAR is a char in MultiByte String env (MBCS) and wchar_t if UNICODE #if defined(WIN32) || defined(UNDER_CE)
0
7692
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7457
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7791
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5360
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5078
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3491
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1921
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1045
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
744
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.