By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,194 Members | 884 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,194 IT Pros & Developers. It's quick & easy.

String problem

P: n/a
Hi

i have the following string

<form
action="http://login.myspace.com/index.cfm?fuseaction=login.process&MyToken=034c2c4 f-4edd-42d7-963a-bf4284966b9a"
method="post" name="theForm" id="theForm">
<div class="row">
<label for="email">E-Mail:</label>
<input type="text" name="email" id="email" value="" />
</div>
<div class="row">
<label for="password">Password:</label>
<input name="password" type="password" id="password" /><br />
</div>
<div class="clear" style="margin-left:-8px; margin-bottom:3px;">
<input type="checkbox" name="Remember" value="Remember"
id="checkbox" />
<label for="checkbox">Remember Me</label><br />
</div>
<div style="margin-left:21%">
<input type="image" id="loginbutton" name="loginbutton"
src="http://x.myspace.com/images/button_login_main.gif"
alt="Log In" onclick="return doSubmit();">
<a id="ctl00_Main_SplashDisplay_login_HyperLink1"
href="http://signup.myspace.com/index.cfm?fuseaction=join"><img
src="http://x.myspace.com/images/button_signup_main.gif"
style="border-width:0px;" /></a><br />
<a
href="http://viewmorepics.myspace.com/index.cfm?fuseaction=user.retrievepassword"
class="right">Forgot your password?</a>
<div class="clear"></div>
</div>
</form>

and want to extract the string from this which looks like
http://login.myspace.com/index.cfm?f...a-bf4284966b9a

how this string will be extracted.

CrimeMaster

Jun 29 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
CrimeMaster wrote:
Hi

i have the following string

<form
action="http://login.myspace.com/index.cfm?fuseaction=login.process&MyToken=034c2c4 f-4edd-42d7-963a-bf4284966b9a" method="post" name="theForm" id="theForm">
<div class="row">
<label for="email">E-Mail:</label>
<input type="text" name="email" id="email" value="" />
</div>
<div class="row">
<label for="password">Password:</label>
<input name="password" type="password" id="password" /><br />
</div>
<div class="clear" style="margin-left:-8px; margin-bottom:3px;">
<input type="checkbox" name="Remember" value="Remember"
id="checkbox" />
<label for="checkbox">Remember Me</label><br />
</div>
<div style="margin-left:21%">
<input type="image" id="loginbutton" name="loginbutton"
src="http://x.myspace.com/images/button_login_main.gif"
alt="Log In" onclick="return doSubmit();">
<a id="ctl00_Main_SplashDisplay_login_HyperLink1"
href="http://signup.myspace.com/index.cfm?fuseaction=join"><img
src="http://x.myspace.com/images/button_signup_main.gif"
style="border-width:0px;" /></a><br />
<a
href="http://viewmorepics.myspace.com/index.cfm?fuseaction=user.retrievepassword" class="right">Forgot your password?</a>
<div class="clear"></div>
</div>
</form>

and want to extract the string from this which looks like
http://login.myspace.com/index.cfm?f...a-bf4284966b9a
how this string will be extracted.


Define what you mean by "looks like". Which criteron should be used to
decide which part is the string you want?

Jun 29 '06 #2

P: n/a
On 29 Jun 2006 01:59:49 -0700, "CrimeMaster" <aj******@gmail.com>
wrote:
Hi

i have the following string

<form
action="http://login.myspace.com/index.cfm?fuseaction=login.process&MyToken=034c2c4 f-4edd-42d7-963a-bf4284966b9a"
method="post" name="theForm" id="theForm">
<div class="row">
<label for="email">E-Mail:</label>
<input type="text" name="email" id="email" value="" />
</div>
<div class="row">
<label for="password">Password:</label>
<input name="password" type="password" id="password" /><br />
</div>
<div class="clear" style="margin-left:-8px; margin-bottom:3px;">
<input type="checkbox" name="Remember" value="Remember"
id="checkbox" />
<label for="checkbox">Remember Me</label><br />
</div>
<div style="margin-left:21%">
<input type="image" id="loginbutton" name="loginbutton"
src="http://x.myspace.com/images/button_login_main.gif"
alt="Log In" onclick="return doSubmit();">
<a id="ctl00_Main_SplashDisplay_login_HyperLink1"
href="http://signup.myspace.com/index.cfm?fuseaction=join"><img
src="http://x.myspace.com/images/button_signup_main.gif"
style="border-width:0px;" /></a><br />
<a
href="http://viewmorepics.myspace.com/index.cfm?fuseaction=user.retrievepassword"
class="right">Forgot your password?</a>
<div class="clear"></div>
</div>
</form>

and want to extract the string from this which looks like
http://login.myspace.com/index.cfm?f...a-bf4284966b9a

how this string will be extracted.

CrimeMaster

I assume that you are looking for a URL. A URL can be identified by
the fragment "://". All the URLs in your example start with http, so
you might want to try "http://" or "HTTP://" if you don't want other
forms of URL (https:// for instance). All the URLs in your example
start and finish with a '"', if this is always the case then use these
to identify the start and end of each URL.

Pseudocode:
proc findURLs
repeat
search for "://"
if "://" found
scan back to previous '"'
scan forward to next '"'
copy text between two quotes to list of URLs
endif
until no more text to search
endproc

That will allow you to identify and extract all the URLs. Beyond that
you are going to have to let us know what it is you are looking for in
the particulat URL you want to end up with, or is it just the first
URL in the file?

rossum

Jun 29 '06 #3

P: n/a

rossum wrote:
I assume that you are looking for a URL. A URL can be identified by
the fragment "://". All the URLs in your example start with http, so
you might want to try "http://" or "HTTP://" if you don't want other
forms of URL (https:// for instance). All the URLs in your example
start and finish with a '"', if this is always the case then use these
to identify the start and end of each URL.


Not all URIs have the "://", but all non-relative URIs have a scheme
followed by a colon. What follows depends on the scheme.

Also, it is perfectly valid to put relative URIs into (X)HTML. In order
to be sure to catch the URIs you have to parse the (X)HTML - no trivial
task - or use a pattern match like you suggest, but understand that it
won't catch everything.

The OP really needs to say what his goal is rather than just provide an
example.
K

Jun 29 '06 #4

P: n/a
thanks
its done

CrimeMaster
Kirit Sælensminde wrote:
rossum wrote:
I assume that you are looking for a URL. A URL can be identified by
the fragment "://". All the URLs in your example start with http, so
you might want to try "http://" or "HTTP://" if you don't want other
forms of URL (https:// for instance). All the URLs in your example
start and finish with a '"', if this is always the case then use these
to identify the start and end of each URL.


Not all URIs have the "://", but all non-relative URIs have a scheme
followed by a colon. What follows depends on the scheme.

Also, it is perfectly valid to put relative URIs into (X)HTML. In order
to be sure to catch the URIs you have to parse the (X)HTML - no trivial
task - or use a pattern match like you suggest, but understand that it
won't catch everything.

The OP really needs to say what his goal is rather than just provide an
example.


K


Jun 30 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.