473,378 Members | 1,543 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

search string using case sensitive

epots9
1,351 Expert 1GB
sorry in advance, i'm just tried..

ok, i need to search a string for something and i want it to return the location of where in the string it is (like the function strpos()), but i need to know the location of where a lowercase letter is immediately followed (no space, no thing between) by a uppercase letter.

I have a feeling it has to done using regular expressions (not sure), and i'm not the greatest at those right now....

open to all suggestions,

Thank You.
Jun 26 '07 #1
5 1487
nomad
664 Expert 512MB
sorry in advance, i'm just tried..

ok, i need to search a string for something and i want it to return the location of where in the string it is (like the function strpos()), but i need to know the location of where a lowercase letter is immediately followed (no space, no thing between) by a uppercase letter.

I have a feeling it has to done using regular expressions (not sure), and i'm not the greatest at those right now....

open to all suggestions,

Thank You.
Ideal here
use

strtolower() function to convert everything in lower case
then use ucfist() to convert the first letter in a string as an upper case.

You will know that the second letter is in lower case.
nomad
Jun 26 '07 #2
pbmods
5,821 Expert 4TB
ok, i need to search a string for something and i want it to return the location of where in the string it is (like the function strpos()), but i need to know the location of where a lowercase letter is immediately followed (no space, no thing between) by a uppercase letter.
Regular expressions unfortunately won't help a whole lot because there's no preg_pos function. But you can do this:

Expand|Select|Wrap|Line Numbers
  1. $array = preg_split('/[a-z][A-Z]/', $string, 1);
  2. if(empty($array[1]))
  3.     // Not found
  4. else
  5.     $offset = strlen($array[0]);
  6.  
If your $string were '012345nG89' (expected return value will be 6), then preg_split would divide the string into:

Expand|Select|Wrap|Line Numbers
  1. array(
  2.     0 => '012345'
  3.     1 => '89'
  4. )
  5.  
If you strlen() the 0th element of that array, you get 6.

[EDIT: Not sure if $array[1] will be set if the target pattern is at the end of the string (e.g., '012345nG').]
Jun 26 '07 #3
epots9
1,351 Expert 1GB
thank you, thats what i needed
Jun 27 '07 #4
sandyw
122 100+
sorry in advance, i'm just tried..

ok, i need to search a string for something and i want it to return the location of where in the string it is (like the function strpos()), but i need to know the location of where a lowercase letter is immediately followed (no space, no thing between) by a uppercase letter.

I have a feeling it has to done using regular expressions (not sure), and i'm not the greatest at those right now....

open to all suggestions,

Thank You.
which tread do you use to solve the problem?
sandy
Jun 27 '07 #5
epots9
1,351 Expert 1GB
which tread do you use to solve the problem?
sandy
i used pbmods's suggestion
Jun 27 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: Anand Pillai | last post by:
To search a word in a group of words, say a paragraph or a web page, would a string search or a regexp search be faster? The string search would of course be, if str.find(substr) != -1:...
2
by: chelleybabyger | last post by:
Below is my sql search code in my asp page. But my search seems to be case sensitive. How can i modify it to make it not case sensitive? Thanks <% sqlString = "SELECT product_image, product_name,...
1
by: ericswebber | last post by:
Case Insensitive Search with Sensitive Replace -------------------------------------------------------------------- Need a REGEX case insensitve search & replace where case of found string is...
7
by: srinivembu | last post by:
Hi, I am trying to port my application from SQLite to MySQL database. I believe MySQL by default searches string in case insensitive manner while using '=' and 'like' operators in SELECT...
0
Debadatta Mishra
by: Debadatta Mishra | last post by:
Introduction In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.