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

Parsing Data in ASP

P: n/a
I have a select statement that gives me the following results (for
example) "test documentation/software product version document.doc" I
need to parse the data to only grab everything between the "/" and
".". So, in other words, "software product version document" - I have
absolutley no idea how to do this - can anyone help????

Thanks in advance!
Lisa
Jul 19 '05 #1
Share this Question
Share on Google+
9 Replies


P: n/a
Lisa wrote:
I have a select statement that gives me the following results (for
example) "test documentation/software product version document.doc" I
need to parse the data to only grab everything between the "/" and
".". So, in other words, "software product version document" - I have
absolutley no idea how to do this - can anyone help????

Thanks in advance!
Lisa

I need to ask: is this truly represtative of your data? Could there be more
than one "/", or more than one "."? If so, you need to let us know if you
want the parsing to start at the first or last incidence of each character.

Do you need the Select statement to return the entire string? If not, then
let us know what database type and version you are using so we can show you
how to do it in your query.

If you need both the entire string, and you need to parse it as well, then
you will be better off doing it in vbscript in your asp page.
Bob Barrows

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 19 '05 #2

P: n/a
Bob,
Yes that is an actual representative of my data. The only "variable"
would be anything betweem "/" and ".". An actual example of my select
results is: "Testing Documentation/Borland JBuilder 6.0 Validation
Document.doc"

My code looks like this:
Dim strOldDocName, strIncremental, GetFileName, fullFileName
strOldDocName = softwareManufacturer + " " + softwareProduct + " " +
softwareVersion

set OBJcmd = Server.CreateObject("Adodb.command")
Set OBJcmd.ActiveConnection = oConn OBJcmd.CommandText = "SELECT * FROM
DocMd WHERE URL LIKE '%" & strOldDocName & "%' ORDER BY URLID DESC;"
Set rs = OBJcmd.execute

fullfilename = rs.Fields("URL")- this is was generates the data
mentioned above.

strIncremental = FullFileName + "1"

I need "strIncremental" to actually equal Parsed(FullFileName) + 1

If NOT rs.EOF THEN
GetFileName = strIncremental
Else
GetFileName = strOldDocName
End If

Lisa

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 19 '05 #3

P: n/a
Lisa . wrote:
Bob,
Yes that is an actual representative of my data. The only "variable"
would be anything betweem "/" and ".". An actual example of my select
results is: "Testing Documentation/Borland JBuilder 6.0 Validation
Document.doc"
You see? There are two "."'s there. Will it always be the last "." that you
want?

My code looks like this:
Dim strOldDocName, strIncremental, GetFileName, fullFileName
strOldDocName = softwareManufacturer + " " + softwareProduct + " " +
softwareVersion

set OBJcmd = Server.CreateObject("Adodb.command")
Set OBJcmd.ActiveConnection = oConn OBJcmd.CommandText = "SELECT *
Don't be lazy. Avoid select * in production code:
http://www.aspfaq.com/show.asp?id=2096
FROM DocMd WHERE URL LIKE '%" & strOldDocName & "%' ORDER BY URLID
DESC;" Set rs = OBJcmd.execute

fullfilename = rs.Fields("URL")- this is was generates the data
mentioned above.


Will you be doing anything else with fullfilename besides parsing it? Based
on this code, the answer is no, but there may be code you haven't shown us

Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 19 '05 #4

P: n/a
You see? There are two "."'s there. Will it always be the last "." that
you
want?
I see your point. Yes I will always want the last "." in the string

and that will be my only referrence to FullFileName.

Lisa

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 19 '05 #5

P: n/a
Lisa . wrote:
You see? There are two "."'s there. Will it always be the last "."
that you
want?
I see your point. Yes I will always want the last "." in the string

and that will be my only referrence to FullFileName.

Lisa

What database are you using? This can probably be done in your query.

Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 19 '05 #6

P: n/a
Is it possible to check Hotmail email with an ASP?
Jul 19 '05 #7

P: n/a

sorry I thought I posted my database info in my last message... I'm
using SQL 7

~L~
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 19 '05 #8

P: n/a
Lisa . wrote:
sorry I thought I posted my database info in my last message... I'm
using SQL 7

~L~


OK, here's a SQL 7+ solution (you should probably encapsulate this in a
stored procedure rather than using dynamic sql):

Dim sSQL
sSQL = Select substring(REVERSE(Right(reverse(URL), " & _
"len(URL) - charindex('.',REVERSE(URL)))),charindex('/',URL) " & _
"+ 1,100) as filename FROM DocMd WHERE URL LIKE '%" & _
strOldDocName & "%' ORDER BY URLID DESC;"
'for debugging:
'response.write sSQL
Set rs=oConn.Execute(sSQL,,1)
parsedFilename = rs("filename")

Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 19 '05 #9

P: n/a
Bob,
I found what I was looking for....thought I would share, thanks!

Dim strOldDocName, strIncremental, GetFileName, fullFileName
strOldDocName = softwareManufacturer + " " + softwareProduct + " " +
softwareVersion

set OBJcmd = Server.CreateObject("Adodb.command")
Set OBJcmd.ActiveConnection = oConn
OBJcmd.CommandText = "MY SELECT STATEMENT;"
Set rs = OBJcmd.execute

fullFileName = rs.Fields("URL")
Dim text, found, arrText, newDoc
text = fullfilename
arrText = Split(text,"/")
For each item in arrText
if InStr(item,".doc") > 0 then
newDoc=replace(item,".doc","")
end if
next
strIncremental = newDoc + "1"
If NOT rs.EOF THEN
GetFileName = strIncremental
Else
GetFileName = strOldDocName
End If

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 19 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.