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


Similar Posts:


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 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 :: 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

Regex :: Replace Portion Of String With A Variable String?

Feb 10, 2012

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

permanentContainer-temporaryContainer- temporaryContainer

View 2 Replies

Regex :: Replace All Instances Of Sub String In String

Jun 21, 2010

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?

View 3 Replies

Regex :: Regexp To Get Domain From URL?

Aug 7, 2010

Regexp for AS3 to get the domain name from URL?[URL]

View 2 Replies

Regex :: What Does This Regexp Pattern Mean

Mar 21, 2011

I'm working with some Action Script file and I found this:

var pattern:RegExp = /.*//
var results:Array = pattern.exec(cardImageService.url);

I know it's a regular expression and that exec() is looking for my pattern in my string. But how should I understand this pattern?

View 5 Replies

Regex :: Using A Variable In Regexp?

Jul 11, 2011

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.

View 2 Replies

Regex :: Match Something With RegExp Between Roundbrackets?

Jun 25, 2009

I have this:

var regExp:RegExp = new RegExp("((.*?)%)");

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.

View 2 Replies

Regex - RegExp Search Field For Filter Function In Flex?

Oct 15, 2009

I have a datagrid and a search field. I've set the change event of the search field to run the filterfunction of the datagrid. I'm able to match the entire term, but I'd like to be able to use a regular expression to do a progressive search (e.g., "Pe" matches "Peter"). I tried to create a regular expression to compare the fields, but I can't seem to get it to work. How do I return the results of the RegExp? Here's the function as it currently stands

[Code]...

View 1 Replies

ActionScript 2.0 :: Flash RegExp - How To Replace Some Characters

Sep 28, 2011

I want to make replace some character. I want to make str = Tanitim-Filmimiz. But I can't do this.
Code:
import RegExp.as;
var pattern:Array = new Array();
pattern[0] = new RegExp("s","s")
pattern[1] = new RegExp("s","s")
pattern[2] = new RegExp("g","g")
[Code] .....

View 1 Replies

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

View 6 Replies

AS :: Flash - Replace All The Links In A Text Using Regex?

Nov 17, 2009

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';

[code]......

View 3 Replies

Regex :: Flex : Replace All Spaces With Comma?

Mar 24, 2010

im new with regexp, so can i ask for some assistance

Using string.replace function what code that can replace spaces with comma

Input:The quick brown fox jumps over the lazy dog.

Output:The,quick,brown,fox,jumps,over,the,lazy dog.

View 1 Replies

ActionScript 3.0 :: Flash String.Replace Won't Replace "%20" From An Original String

Jun 22, 2011

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.

[Code]...

View 5 Replies

Regex :: Extract Specific Parts Of A URL And Replace With Different Data?

Sep 9, 2011

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?

View 3 Replies

ActionScript 3.0 :: Regex To Replace Straight Quotation Marks

Sep 3, 2009

I'm having problem converting single ' and double " straight quotations to curly quotation marks: � � and � � in a long parsed xml data.

View 2 Replies

Regex :: Use The String.match Method To Find Multiple Occurrences Of The Same Word In A String?

May 25, 2010

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.

how the string.match method is and if so

View 1 Replies

ActionScript 3.0 :: .replace Won't Replace - Array With A String As Each Entry

Sep 21, 2010

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.

View 4 Replies

Actionscript 3 :: Regex - Regular Expression - Replace The Spaces At The Beginning (inside The > <) For Other Character

Jun 24, 2011

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.

View 2 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

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 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 :: 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 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

Regex :: Replace Contiguous Line Feeds Or New Line Characters With A Single Newline In Flex

Dec 26, 2011

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.

I am using flex 4.5.

View 2 Replies

Regex :: Replacing Segments Of A String?

Jun 6, 2011

I have absolutely no knowledge in Regex whatsoever. Basically what I'm trying to do is have an error class that I can use to call errors (obviously) which looks like this:

package avian.framework.errors
{
public class AvError extends Object
{

[Code].....

The idea is to replace {0} with the first parameter parsed in ...params, {1} with the second, etc.

I've done a bit of research and I think I've worked out that I need to search using this pattern:

var pattern:RegExp = /{d}/;

View 3 Replies

Regex :: AS3 - Getting X And Y Value Of Matched String In TextField

Jul 13, 2011

I have a text field within Flash that contains a block of (obviously) text. What I want to do is perform a search on the content of the text field that returns the x & y coordinate and the width & height of the found text. The result will be used to place a visual element over that portion of the text box.

For example:
var pattern:RegExp = /d+/g;
var found:Array = box.text.match(pattern);
var i:String;
for each(i in found) {
/**
* Find the x, y, width, height of the matched text in the text field
* Use result to place transparent yellow box around text
*/
}
Which visually should result in something like:

View 1 Replies

Regex :: Flash - Detect Links In A String?

Nov 16, 2009

I am trying to find the generic links in strings. I've found a very handy regex on RegExr, in the community expressions:

(https?://)?(www.)?([a-zA-Z0-9_%]*).[a-z]{2,4}(.[a-z]{2})?((/[a-zA-Z0-9_%]*)+)?(.[a-z]*)?(:d{1,5})?

I tried to use it and it returns null, although the same string tested on RegExr works fine:

var linkRegEx:RegExp = new RegExp("(https?://)?(www.)?([a-zA-Z0-9_%]*).[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.google.com google.com';

[code]....

View 2 Replies







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