String problem

C

CrimeMaster

Hi

i have the following string

<form
action="http://login.myspace.com/index.cfm?...&MyToken=034c2c4f-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?...&MyToken=034c2c4f-4edd-42d7-963a-bf4284966b9a

how this string will be extracted.

CrimeMaster
 
R

Rolf Magnus

CrimeMaster said:
Hi

i have the following string

<form
action="http://login.myspace.com/index.cfm?...&MyToken=034c2c4f-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?...&MyToken=034c2c4f-4edd-42d7-963a-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?
 
R

rossum

Hi

i have the following string

<form
action="http://login.myspace.com/index.cfm?...&MyToken=034c2c4f-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?...&MyToken=034c2c4f-4edd-42d7-963a-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
 
?

=?iso-8859-1?q?Kirit_S=E6lensminde?=

rossum said:
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
 
C

CrimeMaster

thanks
its done

CrimeMaster said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,276
Latest member
Sawatmakal

Latest Threads

Top