473,397 Members | 2,056 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Need help with substring

Hello! I have a problem! Look at this html code:

Expand|Select|Wrap|Line Numbers
  1. <a href="javascript:reportaUser( '33452186' , 'bella33' );">Reporta Contenido Ofensivo</a>
i need to put only this numbers 33452186 in the textbox.Let's say i have 2 textboxes, textbox1 which contains
Expand|Select|Wrap|Line Numbers
  1. <a href="javascript:reportaUser( '33452186' , 'bella33' );">Reporta Contenido Ofensivo</a>
and textbox2 where i need to put the number 33452186. How can i do it? Because i've used indexof and lastondexof:

Expand|Select|Wrap|Line Numbers
  1.             int i = textBox1.Text.IndexOf("'") + 1;
  2.             int j = textBox1.Text.LastIndexOf("'");
  3.             textBox2.Text=textBox1.Text.Substring(i,j-i); 
But it doesn't work. can anyone help me
Oct 16 '08 #1
8 1158
r035198x
13,262 8TB
Check the snippet I posted in this thread. It grabs all the numbers and puts them into an array. If your name is always the first one then you can grab the first element of that array.
Oct 16 '08 #2
Check the snippet I posted in this thread. It grabs all the numbers and puts them into an array. If your name is always the first one then you can grab the first element of that array.
ok but in my case it should be like this?

Expand|Select|Wrap|Line Numbers
  1.             string s = "reportaUser( '33452186'";
  2. foreach(string strItem in Regex.Split(s,"\\D")){
  3.     textBox1.Text = strItem;
  4.  
?
Oct 16 '08 #3
Plater
7,872 Expert 4TB
ok but in my case it should be like this?

Expand|Select|Wrap|Line Numbers
  1.             string s = "reportaUser( '33452186'";
  2. foreach(string strItem in Regex.Split(s,"\\D")){
  3.     textBox1.Text = strItem;
  4.  
?
The result of that code will be the LAST number in your entry string (you called it s) will be displayed.
This works for your sample string, but might cause problems later on???
Oct 16 '08 #4
Thanx ! it works fine!
Oct 16 '08 #5
r035198x
13,262 8TB
The result of that code will be the LAST number in your entry string (you called it s) will be displayed.
This works for your sample string, but might cause problems later on???

Yep, also that Split returns empty spaces so there is need to discard them somehow ...
Expand|Select|Wrap|Line Numbers
  1. string s = "reportaUser( '33452186'";
  2.         string[] numbersandspaces = Regex.Split(s,"\\D");
  3.  
  4.         [foreach (string str in numbersandspaces) {
  5.             if(str != "") {    
  6.                 //
  7.                                Console.WriteLine(str);
  8.             }
  9.         }
Oct 16 '08 #6
But one questions, if the number is different? i mean im creating request from the web, with 1 user profile i get her id which is the number you see here, but when the number is different. for exmaple: 395782958, in this case, how can i generate this random numbers in textbox?

Thanx
Oct 16 '08 #7
when the number ins't known?
Oct 16 '08 #8
Plater
7,872 Expert 4TB
Try it out, instead of using a hardcoded string, use the value of the textbox?
Oct 16 '08 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: Nikita A. Visnevski | last post by:
Hi everyone, I am rather new to Java beans. Just picked up a book last night and started reading about them. I am building an application that allows a user to define objects with dynamic...
9
by: netpurpose | last post by:
I need to extract data from this table to find the lowest prices of each product as of today. The product will be listed/grouped by the name only, discarding the product code - I use...
2
by: mallard134 | last post by:
Could someone please help a newbee vb programmer with a question that is driving me crazy. I am trying to understand a line of code that is supposed to return the domain portion of a valid email...
2
by: m.k.ball | last post by:
Thanks Rich - that's great. Before I found this group, I thought I had a reasonable understanding of SQL (well, MySQL's implementation of it, at least) but the truth is there are great chunks that...
2
by: manmit.walia | last post by:
Hello All and Thank You for your time, I am stuck on this exception handleing error. The problem is that when I run my application the application works perfect but sometimes, I get this error. I...
1
by: sommarlov | last post by:
Hi everyone >From one of our systems an xml file is produced. I need to validate this file before we send it to an external system for a very lenghty process. I cannot change the xml file layout....
10
by: Learner | last post by:
Hello, I am trying to create few dynamic controls and once they are rendered I need to save the information that was entered into these dynamic fileds. For instance when I create 3 radio button...
16
by: manmit.walia | last post by:
Hello All, I have tried multiple online tools to convert an VB6 (bas) file to VB.NET file and no luck. I was hoping that someone could help me covert this. I am new to the .NET world and still...
6
by: zaina | last post by:
hi everybody i am nwebie in this forum but i think it is useful for me and the member are helpful my project is about connecting client with the server to start exchanging messages between...
4
by: Jonathan Wood | last post by:
I'm trying to duplicate an HTML sample I have using my ASP.NET pages. The sample contains the following within the <headtag: <script type="text/javascript" src="flashobject.js"></script>...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.