Solved

get substring of an string

Posted on 2014-04-02
10
274 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 29

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 36

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
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 
LVL 20

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 20

Expert Comment

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

Expert Comment

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

Featured Post

Automating Terraform w Jenkins & AWS CodeCommit

How to configure Jenkins and CodeCommit to allow users to easily create and destroy infrastructure using Terraform code.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

627 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