473,379 Members | 1,533 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,379 software developers and data experts.

finding location (start and lengh) of a substring in a bigger string.

Hi,

Im struggling here ... is it possible to check for a string pattern
like a valid url in a bigger string. And then return the matching
pattern string?

so if i had a string like : "This is my website it is called www.google.com
and i have made lots of money"
Now how can i match a url in this string.... or any url for that
matter and return it?

In this case it would return "www.google.com".

Thanks in advance.

Sep 24 '07 #1
2 1361

"Moham12345" <m_******@hotmail.comwrote in message
news:11**********************@w3g2000hsg.googlegro ups.com...
Hi,

Im struggling here ... is it possible to check for a string pattern
like a valid url in a bigger string. And then return the matching
pattern string?

so if i had a string like : "This is my website it is called
www.google.com
and i have made lots of money"
Now how can i match a url in this string.... or any url for that
matter and return it?

In this case it would return "www.google.com".

Thanks in advance.
www.php.net and look at strstr and related functions.

Shelly
Sep 24 '07 #2

"Moham12345" <m_******@hotmail.comwrote in message
news:11**********************@w3g2000hsg.googlegro ups.com...
Hi,

Im struggling here ... is it possible to check for a string pattern
like a valid url in a bigger string. And then return the matching
pattern string?

so if i had a string like : "This is my website it is called
www.google.com
and i have made lots of money"
Now how can i match a url in this string.... or any url for that
matter and return it?

In this case it would return "www.google.com".

Thanks in advance.
You might also need to look at strtok and substr. For example, find the
postion of "www." or "http://: in the string and take the substring of
that. Then take only until the space. Alternatively, you could look at
"explode" and take the one in the array that begins with "www." or
"http://". Of course, if your URL does not begin with "www." or "http://",
then I am not sure how to do it. I would have to investigate that myself,
but you can do that homework as well as I can.

Shelly

Sep 24 '07 #3

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

Similar topics

13
by: yaipa | last post by:
What would be the common sense way of finding a binary pattern in a ..bin file, say some 200 bytes, and replacing it with an updated pattern of the same length at the same offset? Also, the...
4
by: Victor Engmark | last post by:
When looking for a method to fetch unique elements and counting the number of occurences of each of them, I found quite a lot of gross examples of complex XSL. But after realizing the subtle...
8
by: Phil Powell | last post by:
if (document.location.href.indexOf('?') >= 0) document.location.href = document.location.href.substring(0, document.location.href.indexOf('?')); if (document.location.href.indexOf('#') >= 0) {...
5
by: giampiero mu | last post by:
hi everyone my target is implement a function controlla(string - a binary string-) that check if there is in a string two equal not overlapping subsequences at least of length limitem: my...
2
by: Badass Scotsman | last post by:
Hello, Using VB and ASP,NET I would like to be able to search a STRING for a smaller STRING within, based on the characters which appear before and after. For example: String1 = " That was...
2
by: Gidi | last post by:
Hello, I've a strange problem with substring function. I'm geting a string from my SQL DataBase and i want to split it to two substings. here is what i do: if(temp.Length>80 &&...
2
by: Extremest | last post by:
Here is the code I have so far. It connects to a db and grabs headers. It then sorts them into groups and then puts all the complete ones into another table. Problem I am having is that for some...
2
by: Maxington | last post by:
The problem I am left with is that I need to split a string into substrings and determine the character location of the 30th occurance of "\n" string. I have a string that has "\n" within it and I...
275
by: Astley Le Jasper | last post by:
Sorry for the numpty question ... How do you find the reference name of an object? So if i have this bob = modulename.objectname() how do i find that the name is 'bob'
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: 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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.