473,387 Members | 1,799 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,387 software developers and data experts.

How to do a substring function in actioncript?

93
anybody know how to do a substring function in actionscript pls help~!! I want to do something like extact the number out and convert it to string!
Jul 26 '07 #1
3 5480
xNephilimx
213 Expert 100+
anybody know how to do a substring function in actionscript pls help~!! I want to do something like extact the number out and convert it to string!
Yes, with the substring method:

Expand|Select|Wrap|Line Numbers
  1. var myStr:String = "Hello world";
  2. var mySubstr:String = myStr.substring(6,11);
  3. trace(mySubstr); // outputs: world
  4.  
The following example shows what happens if a negative start parameter is used:

Expand|Select|Wrap|Line Numbers
  1. var myStr:String = "Hello world";
  2. var mySubstr:String = myStr.substring(-5,5);
  3. trace(mySubstr); // outputs: Hello
  4.  
Jul 26 '07 #2
Rocky86
93
Yes, with the substring method:

Expand|Select|Wrap|Line Numbers
  1. var myStr:String = "Hello world";
  2. var mySubstr:String = myStr.substring(6,11);
  3. trace(mySubstr); // outputs: world
  4.  
The following example shows what happens if a negative start parameter is used:

Expand|Select|Wrap|Line Numbers
  1. var myStr:String = "Hello world";
  2. var mySubstr:String = myStr.substring(-5,5);
  3. trace(mySubstr); // outputs: Hello
  4.  
thx for replying mind if I ask substring(6,11); 6 stand for ? and the 11 stand for?
Jul 27 '07 #3
xNephilimx
213 Expert 100+
thx for replying mind if I ask substring(6,11); 6 stand for ? and the 11 stand for?
yes, sorry, I forgot to explain, the method has two parameners, start and end

substring(start, end)

the start parameter is the parameter from which the method will start getting the characters, and the end param is up to which character will get.

if you pass a nevgative value as the start param, it will start counting the start from the last position minus the negative start parameter up to the end parameter. So if you do this:

Expand|Select|Wrap|Line Numbers
  1. var myStr:String = "Hello world";
  2. var mySubstr:String = myStr.substring(-5,5);
  3.  
mySubstr will now have a value of "world". It is, in this case, the same as this:

Expand|Select|Wrap|Line Numbers
  1. var myStr:String = "Hello world";
  2. var mySubstr:String = myStr.substring(6,11);
  3.  
In both of these examples mySubstr will have a value of "world";

If there's anything you didn't understand, please let me know.

Kind regards
Jul 27 '07 #4

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

Similar topics

7
by: Radhika Sambamurti | last post by:
Hi, I've written a substring function. The prototype is: int substr(char s1, char s2) Returns 1 if s2 is a substring of s1, else it returns 0. I have written this program, but Im sure there is an...
62
by: Jupiter | last post by:
Hey, I would like to know 2 things. 1)Is there any function (in C standard library) that extracts a substring from a string? 2)Is there any function (in C standard library) that returns the...
6
by: becte | last post by:
I am little bit confused Is this a legal way of removing a substring from a string? What about the second alternative using strcpy, is it ok even though the source and dest. strings overlap? ...
11
by: Darren Anderson | last post by:
I have a function that I've tried using in an if then statement and I've found that no matter how much reworking I do with the code, the expected result is incorrect. the code: If Not...
2
by: David Filion | last post by:
Hi, I have a question about substring(), when I run the following query: prepaid=# select substring('15148300', 0, 5); substring ----------- 1514 (1 row)
29
by: Ajay | last post by:
Hi all,Could anybody tell me the most efficient method to find a substr in a string.
2
by: Badass Scotsman | last post by:
Hello, Using VB and ASP,NET I would like to be able to search a STRING for a smaller STRING within, based on the characters which appear before and after. For example: String1 = " That was...
6
by: kellygreer1 | last post by:
What is a good one line method for doing a "length safe" String.Substring? The VB classes offer up the old Left function so that string s = Microsoft.VisualBasic.Left("kelly",200) // s will =...
7
by: jknaty | last post by:
I'm trying to create a function that splits up a column by spaces, and I thought creating a function that finds the spaces with CHARINDEX and then SUBSTRING on those values would an approach. I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.