473,657 Members | 2,554 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to do a substring function in actioncript?

93 New Member
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 5501
xNephilimx
213 Recognized Expert New Member
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 New Member
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 Recognized Expert New Member
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
8578
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 easier way to do this. I am hoping someone can point me to a more elegant way of writing this same function. //// code follows /////////// //implement a substring function, where if string2 is a sub of string 1, then the value returned is 1...
62
31884
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 position of a substring in a string? Thx a lot...
6
22732
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? // Remove (first occurence of) sub from src void func(char *src, char *sub) { char *p;
11
5339
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 (strIn.Substring(410, 10).Trim = "") Then 'Something processed Else 'Something processed
2
2021
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
51737
by: Ajay | last post by:
Hi all,Could anybody tell me the most efficient method to find a substr in a string.
2
3172
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 a tasty burger"
6
9261
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 = "kelly" with no error // but string s2 = "kelly".Substring(0,200) // results in // ArgumentOutOfRangeException
7
4224
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 get an error saying that the I have an Invalid column 'Course_Number'. Not sure why but I am very new to User Defined Functions. Here is what I have so far: CREATE FUNCTION CourseEvalBreakdown (
0
8305
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8730
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8503
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7321
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6163
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4301
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1950
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.