ActionScript 3.0 :: Regex To Replace And Transform?
May 12, 2009
what is the best Regular Expression code to transform StringA to StringB? StringA: III Class (1, 7, 9 and 4). IV Class 6, 8, 3. I Class 2-8 StringB: 3rd Class 1,7,9,4;4th Class 6,8,3;1st Class 2-8
I am using a regular expression to find links in a generic string and highlight that text(underline, a href, anything).Here's what I have so far:
var linkRegEx:RegExp = new RegExp("(https?://)?(www\.)?([a-zA-Z0-9_%]*)\b\.[a-z]{2,4}(\.[a-z]{2})?((/[a-zA-Z0-9_%]*)+)?(\.[a-z]*)?(:\d{1,5})?","g"); var link:String = 'generic links: www.google.com http://www.yahoo.com stackoverflow.com';
I have a specific type url and i need to identify some parts of it and replace with some data, url would be www.something.com@param1={{^User Name^}},param2={{^user id^}},....What i need to do is, identify {{^User Name^}} and {{^user id^}} and replace with my values,Anybody have an idea to do this with flex?
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 need a AS3 regular expression that allows me to find/replace in strings like these:
[Code]...
I want to be able to replace the spaces at the beginning (inside the > <) for other character. It shouldn't affect the number of character at the right of the spaces or the attributes in the value1 definition.
I need to replace multiple contiguous new line/line feed characters in flex with a single new line character.
Example:
The string
"My name is blah blah
My name is blah "
Should be converted to
"My name is blah blah My name is blah "
Hope the example makes it easier to understand.
I am using a component to render it.
I guess using regex would be the easiest way to do this, but still it would be great if people can point me out to references/examples to get this done with ease.
Trying to replace a portion of a string with a "-" if it matches a string variable in AS3.
var re:RegExp = new RegExp(imageArray[j][1],"gi"); trace(imageArray[jTemp][2].replace(re,"-"));
imageArray[jTemp][2] is a string imageArray[j][1] is a string as well I'm not getting the result I expect. I would like trace above to return 'permanentContainer-' Here are the traces for the above variables
I'm trying to work with RegEx to split a large string into smaller sections, and as part of this I'm trying to replace all instances of a substring in this larger string. I've been trying to use the replace function but this only replaces the first instance of the substring. How can I replace al instances of the substring within the larger string?
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'm having trouble with loading in an external image that I can transform with the Senocular Transform Tool class. I have managed to load in the picture but the transform class doesn't seem want to grab it. Eventually I want to us the FileRef to upload the image but I just need to figure out how it works first. Here my code to load in the external image
[Code]...
The transform class can grab the other movieclips but it doesn't want to grab the new image loaded in from the code above.
I'm having some real trouble getting .replace to actually replace something. Here's my code...
[Code]...
I can trace both newFiles[i] and keywords[i][whatever], but the replace doesn't replace anything. The regex is valid as well. I'm using regexr to test it, and it works perfectly there... but will not for me and I don't know why.
I've got a strange situation where I'm replacing the text in a string that I've taken from an XML, but the .replace function for the string keeps failing. I've tried running the example given on the Adobe site, so I know the value I'm trying to replace ("%20") isn't at fault - it's something about the string I have! I've included the code below, but it seems correct. Is there a particular tip I should know when taking XML values into AS3? I'm putting them in strings for this project.
So we have [URL] we need to get out from it protocol, ip/adress, port, actual url (robot10382.flv here) and actions (action=read here) how to parse all that into string vars in one reg exp?
Using Actionscript 3.0 (Within Flash CS5)A standard regex to match any digit is:
var myRegexPattern:Regex = /d/g;
What would the regex look like to incorporate a string variable to match?(this example is an 'IDEAL' not a 'WORKING' snippet) ie:
var myString:String = "MatchThisText" var myRegexPatter_WithString:Regex = /d[myString]/g;
I've seen some workarounds which involve creating multiple regex instances, then combine them by source, with the variable in question, which seems wrong. OR using the flash string to regex creator, but it's just plain sloppy with all the double and triple escape sequences required.There must be some pain free way that I can't find in the live docs or on google.
Basically I am using UTF-8 characters codes u0000 to u0008 as part of a socket server.I need a little regex pattern to replace these chars with somthing like a $ symbol to make them really obvious (while tracing output etc..).I believe it should be something like:
Code: filter:RegExp = new RegExp("[u0000u0001u0002u00..]"); myNewString = myString.replace(filter, "%")
most 3d picture wall animations do this. how do i make the transformation in flash, either by hand or by action script or both?
e.g. initial image the transformed img (the entire image should take the form of trapezium) transformed image should not be like this- in this case, parts of the image is cut off in the black parts.
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've written a url validator for a project I am working on. For my requirements it works great, except when the last part for the url goes longer than 22 characters it breaks. My expression:/((https?)://)([^s.]+.)+([^s.]+)(:d+/S+)/i
It expects input that looks like "http(s)://hostname:port/location". When I give it the input: https://demo10:443/111112222233333444445
it works, but if I pass the input https://demo10:443/1111122222333334444455
it breaks. You can test it out easily at[URL].. Oddly, I can't reproduce the problem with just the relevant (I would think) part /(:d+/S+)/i. I can have as many characters after the required / and it works great. Any ideas or known bugs?
I need 3 different regular expressions one that finds at the beginning of the string a 'D' and a space then a name, so 'D patrickgates hello there' would return 'D patrickgates', or if all possible would return just 'patrickgates' one that will find the @ sign and a name together anywhere in the string so '@patrickgates hello, world' would work and return '@patrickgates' or if at all possible would return just 'patrickgates' one that will find 'RT' and a space and then '@' and the username at the beginning of the string so 'RT @patrickgates' would work if returning just the username and also being true isn't possible with one regex, then I could use one to match to, and one that will delete the 'D' or the '@' or the 'RT'.
The problem is about the regular expression, how can I find this whole line by regular expression?
I am using the RegExp from ActionScript3
The main challenges are:
The <%@ %> instruction may contains another <%$ %> instruction in its attribute, just like the one above The <%@ %> instruction may have a line break in it, just like the following.