ActionScript 3.0 :: RegExp Connundrum - Extracting Numbers From An Alpha-numeric String?

Apr 22, 2009

I I have an alpha-numeric string as a variable. I would like to extract (from left to right) all of the numbers from the string and then push them into an array. Below, is what I have going so far, but it stops after the first number it meets. I was under the impression that the RegExp.exec runs through the entire string before stopping.

var testMenu:RegExp = /d/;
var whichTarget:String = me.target.name[code]..........

when I trace my array, it is just filled with the first number that is encountered. So, in the two examples above the array beomes [1] (when the string that is executed is "menu1sub2hypo3" and then [3] when the string that is executed is "menu3sub4hypo8". It craps out after the first number is reached.What I really want is that the array gets filled with [1, 2, 3] in the first example and [3, 4, 8] in the second example. How in Helsinki would I do that? Does the exec function need to be looped in any way?

Not so important right now but thinking a little down the line: what regular expression would I need to find "25" instead of just "2" if I run this RegExp.exec on a string that may look like this "menu25sub3hypo6"?

View 4 Replies


Similar Posts:


ActionScript 3.0 :: Extracting Numeric Values From Concats

Oct 9, 2010

Is there a way to extract a numeric value from my variable using concatination.

var i:Number = 1;
var test1value:Number = 3;
trace(this["test"+i+"value"]);

I tried all kinds of tricks but I just can get the string name of the variable instead of the value it holds.

View 7 Replies

Professional :: Extracting Numbers Not Strings From Input Text Fields?

Apr 29, 2010

I have two input boxes that I can type numbers into.I'd like a third input box to display the total of the first two.I've set up a key pressed listener on the stage to run a function that adds them together when a key is pressed.Problem is, it just places the strings together - it ddoesn't add them.So how do I tell Flash that box1.text and box2.text are numbers?box3.text = box1.text + box2.text ain't doing it.

View 5 Replies

ActionScript 3.0 :: Extracting The Alpha And Color Channels From A Png To Create A Two Separate Images?

Jun 6, 2011

I'm trying to take a png and create two images, one that represents the color data and the other a grayscale version of the alpha channel.

Extracting the correct data was no problem, i'm just embedding the png, creating a new instance (as a Bitmap) and then extracting the relevent channels of it's bitmapData to two new bitmapData instances.

ActionScript Code:
[Embed(source='/../deploy/images/alpha_test.png')]
public var image  : Class;

[code]....

The problem that i'm having, is that when i assign the colors bitmapData to a bitmap instance to display it, the background color is showing as black, even though the default fillColor of a bitmapData instance is white. how i can use the alpha channel data to create an 8 bit, grayscale image, that's the reverse of the channel?

View 1 Replies

ActionScript 3.0 :: How To Convert String To RegExp

Mar 27, 2009

How to convert a string to a regular expression? Right now if I try to convert a string to a regexp, the regular expression ends up with a / in front and a /g in the back.

View 5 Replies

Professional :: String Formatting/extracting?

Dec 5, 2011

string = justsomerandomstuff.Count:12562morerandomstuffI need to extract the "12562"I never know how far in the string this number will be, but I do know it's 1 character away from the word "Count". Somehow I would need to find the position of the string "Count within the variable, add 1 and extract the numbers. Also the the number is not always the same lenghth, so it would also have to work with this:string = justsomerandomstuff.Count:14238960morerandomstuff.

View 1 Replies

ActionScript 3.0 :: Extracting Message From A String?

Apr 28, 2011

I have a string coming into my flash app that is formatted differently quite often. Sometimes, that string has HTML with various formatting options. I need a way to extract the message regardless of the fact if the person uses <B> , <I> or nothing. Below are sample strings:

STRING 1:
<FONT FACE="Verdana" SIZE="10" COLOR="#0B333C" LETTERSPACING="0" KERNING="0">
<B>
<I>hi hun</I>
</B>

[Code].....

View 6 Replies

Regex :: Flex Add An Avaliable String In Regexp?

Dec 30, 2011

In the below code if i replace st2 into the pattern of regexp without quotes, it works fine.Now since i get the regular expression from some other file, as it is shown in st2. I want to add that into the regexp pattern. But as in the below code it doesnt work.

<fx:Script>
import mx.controls.Alert
public function onClicking(){

[code].....

View 1 Replies

ActionScript 3.0 :: RegExp - Look For ID In Input Text String

Jul 8, 2010

ActionScript Code:
input.text = "[URL]";
function PlayVideo(event:MouseEvent):void {
switch (event.type) {
case "click":
var findVideo:RegExp = /(?<=?v=)([a-zA-Z0-9_-])+/;
trace(findVideo.exec(input.text));
break;
}}

I don't know what video this is (just picked it randomly off of the front page), but by clicking a button, the RegExp is called, looks for an ID in the input.text String, but when it does and I trace it, it gives me this:

ActionScript Code:
QGsGJlCpor4,4
What's with the ,4? How do I get rid of that?

View 3 Replies

ActionScript 2.0 :: Search And Replace String Using RegExp?

Jun 2, 2011

search and replace text nodes from following string:

MY ORIGINAL STRING:
var strTemp = '<p><text textId="textVariable1">This is my first text node.</text></p><question type="first">This is a first question.</question><p><text

[code]....

View 0 Replies

ActionScript 3.0 :: Replacing Spaces In A String, The RegExp Way?

Apr 16, 2009

So I'd like to remove all spaces from an input text box, and replace them with commas, and I'd like to learn how to do this with RegExp, which I've never before used.This doesn't work (though if I do s.search(re) it returns the first space):

Code:
var s:String = searchTerms.text;
var re:RegExp = /s/g;

[code]....

View 2 Replies

ActionScript 3.0 :: Using RegExp To Replace String Inside Another

Aug 15, 2010

I'm having an issue with RegExp. I have a string variable equal to "1 + 2 + 3 + 4". I'm trying to use RegExp to replace that string inside another string, however the plus signs are causing it to not be recognized. If I take the plus signs out, it works. If I replace the plus signs with minus signs, it works. I know + means something in an expression, is there a way I can get flash to ignore it and keep the + sign in there?

View 2 Replies

ActionScript 3.0 :: AIR Handling Large Numbers - Convert A String Having Numbers To An Integer

Feb 18, 2010

I am trying to convert a string having numbers to an integer.

//15 9's are there
var str:String="999999999999999"
var res:Number = new Number(str);

But it is not able to convert correctly as the the var res now has the value 100000000000000000. I know that the number has 52 bits of memory, then why is it not able to do the conversion?

View 6 Replies

Regex - Replace Section Of String With A Dash Using RegExp?

Feb 13, 2012

I would like to be able to replace a section of a string with a dash. The section being replaced will be variable.

var str:String = "permanentContainer-temporaryContainer-"
var test:String = "temp";
var pattern:RegExp = /-[(+test+)]+-/i;
trace( str.replace(pattern,"-"));

I would like the result to trace:

permanentContainer--oraryContainer-

View 2 Replies

Actionscript 3 :: Extracting Links And Twitter Replies From A String?

Sep 16, 2010

I am getting a string from Twitter into my Actionscript which is a unformatted string. I want to be able to extract any links and or any @replies from the string, then display it in htmlText.

So far I have this

var txt:String = "This is just some text http://www.thisisawebsite.com and some more text via @sumTwitter";
var twitterText:String = txt.slice(txt.indexOf("@"),txt.indexOf("

[Code].....

This is fine for extracting links, which finish with a space. But what if, like the @sumTwitter, it finishes at the end of the string. And also what if there are multiple links or @'s, is the best way to put it in a while loop?

View 1 Replies

ActionScript 2.0 :: How To Put Numeric Var In String

Mar 5, 2006

nTest = 1 //numeric
sTest = " test" //string
sFinal = nTest & sTest //string
I get an error with this, because sFinal is a string, and im tryin to put in an numeric value. How can I create this code so that it will work? I want the sFinal to contain "1 test". This code is useless, I know, but this is just an example.

View 4 Replies

ActionScript 3.0 :: RegExp - Trim String Extra White Space?

Dec 12, 2009

I am trying to parse a string in order to remove all extra white spaces.Iām working in AS3 and at the moment the only pattern I found remove all content:

field.text = field.text.replace ("As+|s+z", " ");[code].....

View 3 Replies

ActionScript 2.0 :: Converting From A String To A Numeric?

Feb 6, 2003

I have an mc.instance name is Twentysecond it has a text box called label When clicked Twentysecond populates a text box and I want to use this code Flash will not let me use an instance name of 22nd.

TwentySecond.label = _name;//(I want this to show 22)
onRelease = function(){
myTextBox = _name; // (I want this to show 22nd
}

I should know how to do this, but memory is failing.

View 4 Replies

Regex :: Flex - Extracting Variables From A String Like /var1/var2/var3/?

Aug 4, 2009

I need to extract in actionscript the variables from a string like /var1/var2/var3/...Each variables can be characters or/and number and variable size.My current regex /(w+)/g work for the first variable but not for the others.

var matchExpression:RegExp = /(w+)/g;
var match:Array = matchExpression.exec(browserManager.fragment);

View 4 Replies

ActionScript 3.0 :: Remove All Non-numeric Characters From A String?

Feb 12, 2010

I'm currently searching google whilst I ask this - I just couldn't find anything on my initial searches.Are there any quick ways to remove all non-numeric characters from a string?For example my string would contain:

'code: 1234'

I would wish to remove the 'code: ' part from the string just leaving '1234'.

View 3 Replies

ActionScript 3.0 :: Give An Alphabetic STRING A Numeric Value?

Dec 15, 2010

I`ve got one combobox wich items are named as alfabetic stringsThen one input textfield where u inser numbersThen in the third element on stage (dynamix textfield) wher the result of the calculation is displayed.The problem is that when i try to transform the text string into a numeric value like this it dosent work (example for giving the string "Leds " a value of 300):

var myNumber:Number = 300;
var myString:String = "Leds" (myNumber)
This is the rest of the code without the conversion from text to number working good but

[code]......

View 9 Replies

ActionScript 2.0 :: How To Detect Whether Entered Value Is String Or Numeric

Apr 18, 2002

I have made a form and want to check valid data i.e if alpanumeric value is req. user cannot enter numeric value and vice versa. I found no inbuilt fn. in flash which could detect whether the entered value is string or numeric.

View 4 Replies

ActionScript 2.0 :: "extracting" Variables Into Numbers?

Feb 21, 2009

i've some problem with extracting a variable which i acquired using _name so that the name of movieclip such as in my case "t01" "t02" and so on is extracted because i need to use the "01" and "02" and the rest of the numbers for something else...

View 4 Replies

ActionScript 3.0 :: Extend To String And Change The Numeric Values?

Feb 10, 2010

I'm creating a Inches scale based game.. So I want to change the numeric values like

1.9 + 0.1 = 2 ( Not I need );
1.9 + 0.1 = 1.10
& 1.9 + 0.3 = 2.0 (thats I want)...

for example Ist possible like below class..

Code:
package com.classwork{
public class Inches extends String{
public function Inches(Str:String = "0'0"):void{[code]...........

View 3 Replies

ActionScript 3.0 :: Use String Or Array To Compile Total Numeric Value?

Nov 13, 2010

I am building a remote control, and when i enter txt, right now i can "change the channel" only for a single value 1-9. the way it functions is you hit the number, then an enter button, and the channel changes. The problem is I want to able to enter 2 digits, and the way i have it coded now, it adds the the numbers together instead of reading 1 as 2 , 2 as 4 and so on, here is the code, I'm thinking i should use an array, or a string to get the proper value, but when i use the "+" sign it still adds the number together, how would i express, so it sees 11 as eleven etc?

ActionScript Code:
function storePad(evt:MouseEvent):void {
var aNum:Number = Number(evt.target.name.substr(4))

[code]......

View 4 Replies

ActionScript 3.0 :: String Trailing Numbers From String

Dec 3, 2010

EDIT: The title was supposed to be "Strip trailing numbers from string" I have a few strings that I'm looping through to make sure they all are the same format. Example date

Box
Box
Box2001
Circle
Circle3001
Box2002
Box
Circle

I want to loop though them and strip any trailing numbers from them if thats possible. So it will end up being,

[Code]..

View 4 Replies

Flex :: Grouping Collection Separating Numeric 5 From String "5"?

Apr 8, 2010

I have an advanced data grid. The data provider for this ADG is an ArrayCollection. There is a grouping collection on an ID field of this AC. Example of a couple items within this AC the AC var name is "arcTemplates":

(mx.collections::ArrayCollection)#0
filterFunction = (null)
length = 69
list = (mx.collections::ArrayList)#1

[code]....

Problem: In my AC example there are a few items, items 0, 32 and 56 properly sort and group to their templateTypeID, but item 55 does something weird. It seems to sort/group on the numeric 5 instead of the string "5". Gets stranger. If I change the name property to contain text (so 1234x) it then correctly sorts/groups to the string "5"

View 1 Replies

IDE :: Parsing Numbers From A String?

Mar 30, 2009

I'm trying to find a way to parse out some numbers from a potential string. Basically, I'm making a financial-based calculator, and the user could input something like

$45,509.30

and I'm trying to figure out how to extract everything but the period so I'm left with

45509.30

I found this help from Senocular: [URL]

But unfortunately, it's AS1 and I can't get it to work with my code...t

View 1 Replies

ActionScript 2.0 :: Parse And Add Numbers In A String?

May 1, 2009

I'm wanting to make a small program that when people paste in some long text like below:

05/01/2009 02:14:59 Ad Package Bonus in amount of 4.
05/01/2009 02:14:59 Ad Package acquired in amount of 16.
04/30/2009 11:05:37 Ad Package Bonus in amount of 2.
04/30/2009 11:05:37 Ad Package acquired in amount of 11.

That I can have a button that will ad up the numbers on the right side

So the solution would be: 33

View 6 Replies

Javascript :: Flip Numbers In A String

Apr 29, 2010

I have an issue with some Arabic text where I need to flip numbers inside a string. So this: "Some text written in 1982 by someone with m0123456 or 12-to-13".Should become:"Some text written in 2891 by someone with m6543210 or 21-to-31"

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved