Solved

get substring of an string

Posted on 2014-04-02
10
266 Views
Last Modified: 2014-04-19
hi i have this string below

dim test as string = "javascript: test2(4622,4623)"

i want to get the first number inside the function test2, so the result would be 4622.

how can i accomplish this.
0
Comment
Question by:rafaelrgl
10 Comments
 
LVL 28

Expert Comment

by:sammySeltzer
ID: 39973465
Javascript solution:

<!DOCTYPE html>
<html>
<body>
<script>
var test = "4622,4623";
var measureit = test.substring(0, 4);
document.write(measureit);
</script>
</body>
</html>

Open in new window


vb.net version
Dim test As String = "4622,4623"
Response.Write(test.Substring(0, 4))

Open in new window

0
 
LVL 35

Expert Comment

by:Kimputer
ID: 39973536
Is it always a number? Fixed length? Always enclosed by the open bracket ( and comma?
0
 
LVL 1

Author Comment

by:rafaelrgl
ID: 39973725
is always an number but it~s not fixed size, can be 4 digits, can be 8 digits, but always have the comma after the first number and have the ( before start the number.
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 19

Accepted Solution

by:
n2fc earned 500 total points
ID: 39973776
<!DOCTYPE html>
<html>
<body>
<script>
var test = "javascript: test2(4622,4623)";


i=test.indexOf("(");
j=test.indexOf(",");


var measureit = test.substring(i+1,j);
document.write(measureit);

</script>
</body>
</html>

Open in new window

0
 
LVL 2

Expert Comment

by:Rob Jurd (eenookami)
ID: 40009394
I've requested that this question be deleted for the following reason:

Not enough information to confirm an answer.  No response from anyone involved and doesn't appear to be a solution here.
0
 
LVL 19

Expert Comment

by:n2fc
ID: 40009392
Did he even TRY my solution?   It works!
0
 
LVL 19

Expert Comment

by:n2fc
ID: 40009395
Did he even TRY my solution?   It works!
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
This video discusses moving either the default database or any database to a new volume.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now