find the suitable regular expression to validate a string that has comma separated numbers, for e.g. '1,2,3' or '111,234234,-09', etc. Anything else should be considered invalid. for e.g. '121as23' or '123-123' is invalid. I suppose this must be possible in Flex using regular expression but I can not find the correct regular expression.
I am not new to regex but have come across a problem I can't seem to solve. I'm trying to locate a specific HTML tag that has a specific attribute/value pair (it may have other attributes, too, but those are optional), extract it's contents as a backreference and wrap a new custom tag around it. The original tag is:
I am VERY new to Flash and Action Script (using Flash 8 & AS2) and my company butchered by training budget so I have zero $$s to learn. I have been muddling through with these great forums and tutorials but this has got me stumped.I have a button to calculate some simple math from number stepper components to populate dynamic text boxes.The script I came up with works but I need the return values to have decimal (2) and comma (at the thousands).[code]
and want everything between the ( and the %)the string looks like this: (-24%)I now get a return back "(-24" and have searched for a long time to find a solution but didn't find any.
I am trying to get a regex match on HTML code that is parsed into a text box in flash. I have successfully loaded the HTML code and then began the regex matching, but am stuck on getting the right regex expression to match. The code that I am using in html page builds a tree view list on the html page, so once it's loaded into the flash text box, i am trying to match the html pages to build a list from. The code below is what I am trying to match.
The code I want to match is the first two items in quotes for each entry to build the array list of page names, and their URL. The problem is that the pages won't be named as nice as the example below. Each time it can be a different page name, and page url, so I need to match what is in the first two quotes.
I have a bunch of text fields that display numbers such as 2745345.What i want is a neat bit of code that quickly and simply converts this to 2,745,345.This makes the numbers more easy to read and interpret.
I'm showing the users score in a textbox. But if the number exceeds 1000 it should show 1.000 example: 10000000 => 10,000,000 I've been searching a lot on Google, but I just can't make it work. Can anyone help me with this? I've started something out with this code:
[URL]
Also, if I had the correct function, how would I made it split too if the number was 10.000, 100.000, etc..
Ok perhaps ive bitten off too much here...I know you are not supposed to parse xml/html to regex but the thing is there just arent many other options.Im using AS3.im parsing the source of textflowlayout text to a different format.
string to parse :
< fontFamily=Verdana encoding=unicode fontWeight="bold"> some text < fontFamily=Verdana encoding=unicode > some text < fontFamily=Arial encoding=unicode fontStyle="italic"> some text < fontFamily=Arial encoding=unicode fontWeight="bold" fontStyle="italic"> some text
what i really need is:
< fontname=Verdanabold encoding=unicode> some text < fontname=Verdana encoding=unicode > some text < fontname=Arialitalic encoding=unicode > some text < fontname=Arialbolditalic encoding=unicode > some text
logically i think of it as taking apart the string into substrings
checking if there are fontWeight or fontStyle in the substring
if there is then appending the font name with the weight or style so so that the font name becomes font NameWeightStyle.then rebuilding the string.The font could be any font with variouse styles or weights..so far:
pattern = /<(.*?)>/gixsm; var matches:Object = pattern.exec(str); var finalstring:String = "";[code]...........
I have the following as3 function below which converts normal html with links so that the links have 'event:' prepended so that I can catch them with a TextEvent listener.
protected function convertLinks(str:String):String { var p1:RegExp = /href|HREF="(.[^"]*)"/gs;
[Code]....
How can i modify my function so that links with 'event:' at the start are NOT matched and are left unchanged?
I have the following regex, which will match all the <br> and <br /> tags in a string:
/<br[s|/]*>/gi
I actually want to match every set of two consecutive tags, with valid matches being:
<br><br> <br/><br> <br><br/> <br/><br/> (and all variations with a space before the slash)
Obviously I can just double up the expression to /<br[s|/]*><br[s|/]*>/gi, but is there a shorter way of taking the first expression and saying "this, but twice"?
I've gotten stuck on some issue using AS3 and RegEx. I'm trying to use a RegEx var to match out the ends of a mathematical expressions out of a string. But for some reason, the RegEx only matches the first expression and ignores the one after the conditional.
I'm looking for a regex or a way to format the NumberValidator so that only decimal places are allowed.The domain="real" allows you to put integer values, but I need to force the user to but in 2.0 if they want an integer.This is because they pass through a Castor mapping file, it complains if it gets an integer when it expects a decimal.I dont want to restrict the number of decimal places, just insist that there must be a point, and a number after it.
I am trying to get a regex match on HTML code that is parsed into a text box in flash. I have successfully loaded the HTML code and then began the regex matching, but am stuck on getting the right regex expression to match. The code that I am using in html page builds a tree view list on the html page, so once it's loaded into the flash text box, i am trying to match the html pages to build a list from. The code below is what I am trying to match. The code I want to match is the first two items in quotes for each entry to build the array list of page names, and their URL. The problem is that the pages won't be named as nice as the example below. Each time it can be a different page name, and page url, so I need to match what is in the first two quotes.[code]
In Actionscript and Adobe Flex, I'm using a pattern and regexp (with the global flag) with the string.match method and it works how I'd like except when the match returns multiple occurrences of the same word in the text. In that case, all the matches for that word point only to the index for the first occurrence of that word. For example, if the text is "cat dog cat cat cow" and the pattern is a search for cat*, the match method returns an array of three occurrences of "cat", however, they all point to only the index of the first occurrence of cat when i use indexOf on a loop through the array. I'm assuming this is just how the string.match method is. I want to find the specific indices of every occurrence of a match, even if it is of a word that was already previously matched.
I'm having troubles declaring decimal numbers.For instance I'm trying to create a variable which is 0.8.I do this:
Code: var defenseValue:Number = 0.8;
However, when I try using defenseValue it always ends up being NaN.I also tried var defenseValue:Number = new Number(0.8); But that doens't work either.
I have a function that adds the values of an array together and displays the output in a textArea(myText).
The code below works fine, but the output number is "11.5" I need this to be "11.50" and again if we set the array index [1] to "0" instead of ".50" I would need to show "11.00" instead of "11" which is what I am getting now!
var myArray:Array = new Array(1.50,.50,0,9.50); function addValues(myArray:Array):Number{ var arraySum:Number = 0; for (var i:uint=0; i< myArray.length; i++){ arraySum += myArray[i]; } return arraySum } trace(addValues(myArray)); myText.text = String (addValues(myArray));
whats the quickest way to round to decimal with infinite numbers?
I wanted to round 6.329784432421148+e to 6.3297
using toFixed() rounds to .000001
Only solution I came up with was ,Number ( String( infinite num ).substring(0,6) ); To me this seems slow and CPU intensive, there has to be a more efficient way of accomplishing this.
This is my FLA I need to round the numbers in the farthest columns to 2 decimal points (ie: 19.00 rather than 19). My ultimate goal is to do it globally, but I'm not sure how to do it.
to represent dollar amounts... is there anyway to set the length of a float variable to do this? or is there any kind of dollar datatype in AS? (im using studio mx 2004)
I've frequently come across the issue when placing a movieclip or bitmap, the resting position of said object will land on a decimal value, not a nice, full pixel value. For instance, I drag a movie clip into a scene and it lands on a position of: X: 27.2, Y: 56.9, when I'd like it to be X: 27, Y: 57.
Now, this wouldn't bother me as much if I were dealing only in vector shapes. I currently work as a developer in the videogame industry and often times, for optimization purposes, I need to use both bitmaps and vectors. Plus, as a UI designer, text is very important to use throughout a game's UI. If you notice, when a font gets placed in an in-between position related to pixels, the text becomes blurry looking in appearance (graphical elements around the text can also appear blurry when in between pixel values as well). This can make UI pages or HUDs look sloppy and unprofessional.
I've tried enabling snapping (including enabling the grid, setting the grid to 1x1 pixel, then enabling both pixel snapping and grid snapping), but nothing seems to help in getting objects to place on whole pixels. Yes, I can manually change pixel values to whole numbers (which I'm currently doing). But when you have to manually position 100 keys on a keyboard, it gets old pretty quick!