String replace All using RegExp

var myString:String="<font face='arial' size='14'>ZX</font><span class='cssid'>some Text </span><font face='arial' size='14'>USP</font>"
  var fontName:String="Vardana"
var fontSize:String="11"
  var regexp:RegExp = /<font.*?>/;
  myString = myString.replace(regexp, "<font face='"+fontName+"' size='"+fontSize+"' >");
above scripte replacing only "<font face='arial' size='14'>ZX</font>"
i need to replace   : "<font face='arial' size='14'>ZX</font><span class='cssid'>some Text </span><font face='arial' size='14'>USP</font>"

var regexp:RegExp = /<font.*?>/igm;

Similar Messages

  • Identifying patterns in a string & replacing all characters with 1st digit

    Morning folks. Interesting problem on hand. I have a situation where I have a varchar2 text field where I have different paterns of a sequence of numbers somewhere in the string. I guess, I could write a function where by I accept the whole string and then identify one of the patters below and then finally replace only the recognized pattern with the first digit all the way through to the end of that pattern.
    The catch here is that there could be free text before and after the string but there will be spaces when free text ends and the patern begins.
    Here are a few patterns I would be interested in. The MAX length is 19 as in Cases 1 and 3.
    1. 9999 9999 9999 9999
    2. 9999999999999999
    3. 9999-9999-9999-9999
    4. 9999-9999-99-99999
    5. 9999-999999-99999So, here would be an example of the problem in hand :
    Call received on 9/22/2009.
    5123-4532-8871-9876
    Please follow up by 10/22/2009So, the desired output would be :
    Call received on 9/22/2009.
    5555-5555-5555-5555
    Please follow up by 10/22/2009Any ideas ? I am stumped at the fact of before and after text in the string, hence the question for you guys !
    Thanks !

    Here is another solution. However there has to be a better way! (I'm not a regular expression expert).
    SQL> WITH test_data AS
      2  (
      3          SELECT 'Call received on 9/22/2009.
      4          1232 3456 8765 3456
      5          Please follow up by 10/22/2009' AS DATA FROM DUAL UNION ALL
      6          SELECT 'Call received on 9/22/2009.
      7          1232345687653456
      8          Please follow up by 10/22/2009' AS DATA FROM DUAL UNION ALL
      9          SELECT 'Call received on 9/22/2009.
    10          1232-3456-8765-3456
    11          Please follow up by 10/22/2009' AS DATA FROM DUAL UNION ALL
    12          SELECT 'Call received on 9/22/2009.
    13          1232-3456-86-3456
    14          Please follow up by 10/22/2009' AS DATA FROM DUAL UNION ALL
    15          SELECT 'Call received on 9/22/2009.
    16          1232-345687-3456
    17          Please follow up by 10/22/2009' AS DATA FROM DUAL
    18  ), substring AS
    19  (
    20          SELECT  DATA AS SOURCE
    21          ,       REGEXP_INSTR
    22                  (
    23                          DATA
    24                  ,       '(([[:digit:]])+[[:space:]|-]){1,}'
    25                  ) AS PATSTART
    26          ,       REGEXP_SUBSTR
    27                  (
    28                          DATA
    29                  ,       '(([[:digit:]])+[[:space:]|-]){1,}'
    30                  ) AS PATTERN
    31          ,       19 AS MAXLENGTH
    32          FROM    test_data
    33  )
    34  SELECT  SUBSTR
    35          (
    36                  SOURCE
    37          ,       1
    38          ,       PATSTART-1
    39          ) ||
    40          TRANSLATE
    41          (
    42                  PATTERN
    43          ,       '0123456789'
    44          ,       LPAD
    45                  (
    46                          SUBSTR
    47                          (
    48                                  PATTERN
    49                          ,       1
    50                          ,       1
    51                          )
    52                  ,       10
    53                  ,       SUBSTR
    54                          (
    55                                  PATTERN
    56                          ,       1
    57                          ,       1
    58                          )
    59                  )
    60          ) ||
    61          SUBSTR
    62          (
    63                  SOURCE
    64          ,       PATSTART + MAXLENGTH
    65          )       AS NEW_STRING
    66  FROM substring
    67  /
    NEW_STRING
    Call received on 9/22/2009.
            1111 1111 1111 1111
            Please follow up by 10/22/2009
    Call received on 9/22/2009.
            1111111111111111
          Please follow up by 10/22/2009
    Call received on 9/22/2009.
            1111-1111-1111-1111
            Please follow up by 10/22/2009
    Call received on 9/22/2009.
            1111-1111-11-1111
           Please follow up by 10/22/2009
    Call received on 9/22/2009.
            1111-111111-1111
          Please follow up by 10/22/2009
    SQL>

  • Using applescript for Find and Replace All in Pages 2.0

    i saw that Pages 2.0 is scriptable
    i try to create a script for merge use to find and replace all occurence of a certain string using a script but Pages doesn't seems to respond to "Find" even using "System Events"
    how can i do to use this function with a script
    Thanx for any help
    S.B.
    ibook G3   Mac OS X (10.4.6)  

    OK, here's another example. This one gets the text as a string and uses the offset property to find "[", presuming it to be a merge delimiter. (Pages' text doesn't support "offset of").
    One failing of this scheme is that the offsets are incorrect if you have inline objects (pictures, shapes, tables, etc.). While it is probably possible to compensate for them, that's a trickier proposition.
    <PRE>-- Example merge replacements:
    property mergeText : {"[name]", "John Smith", "[address]", "1234 Anystreet"}
    on lookup(mergeWord)
    set theCount to count of mergeText
    repeat with x from 1 to theCount by 2
    if item x of mergeText = mergeWord then
    return item (x + 1) of mergeText
    end if
    end repeat
    -- If merge field is not found, delete it (replace it with the empty string)
    return ""
    end lookup
    tell application "Pages"
    repeat
    tell body text of document 1
    -- Get text as a string so that "offset of" can be used.
    set allText to it as string
    set startOffset to offset of "[" in allText
    if (startOffset = 0) then
    exit repeat
    end if
    set endOffset to offset of "]" in allText
    select (text from character startOffset to character endOffset)
    end tell
    set mergeWord to contents of selection
    tell me to lookup(mergeWord)
    set replacement to result
    set selection to replacement
    if (replacement is "") then
    -- Get rid of extra whitespace (space or return)
    -- Do it in a "try" block to handle edge cases at start or end of text.
    try
    set theSel to (get selection)
    set ch1 to character before theSel
    set ch2 to character after theSel
    if ((ch1 is " " or ch1 is return) and (ch2 is " " or ch2 is return)) then
    select character after theSel
    delete selection
    end if
    end try
    end if
    end repeat
    end tell</PRE>
    Titanium PowerBook   Mac OS X (10.4.6)  

  • Replacing all occurrences of characters in a string with one new character?

    Hi there,
    I'm looking for a way that I could replace all occurrences of a set of specific characters with just one new character for each occurrence.
    For example if I have a string which is "word1...word2.......word3....word4............word5" how would I be able to replace this with just one character such as ":" for each set of "." so that it would essentially appear like this "word1:word2:word3:word4:word5"
    If I just use replace(".", ":") I am left with "word1:::word2:::::::word4::::word5::::::::::::"
    So therefore I'm guessing this would require the use of replaceAll() maybe? but I'm not really very familiar with how regular expressions work and how this would be accomplished using them.
    Any help would be greatly appreciated :) Thanks.

    Yes, but "." means any character, so ".\+" means "any character repeated more than once". If you just mean a full stop ("period" for you Americans :p) you should use "\.+" as your regular expression, but remember that for Java you need a '\' escape to recognise '\' as '\', so in code you'd actually type your regex as:
    "\\.+"Here's an example of one way to do it:
    import java.util.regex.Matcher;
    import java.util.regex.Pattern;
    public class Test {
        public static void main(String[] args) {
           String string = "example1.......example2...example3.....example4";
         Pattern pattern = Pattern.compile("\\.+");
         Matcher stringMatcher = pattern.matcher(string);
         string = stringMatcher.replaceAll(":");
         System.out.println(string);
    }Edited by: JohnGraham on Oct 24, 2008 5:19 AM
    Edited by: JohnGraham on Oct 24, 2008 5:22 AM

  • Replace all special characters in a String with underscore

    I have a String which contains some special characters even(!,$,@,*....).
    I need to replace all the special characters with _ in my String. I do have an idea of using String.replace() and analogous forms, but I would be thankful if anyone can suggest me of a better and an efficient way.
    regards,
    fun_one

    Kaj,
    Thx for your earnest reply. I did have a peep into the API on this method. But the regular expression that I need to use here was beyond my understanding. It did specify some regex that I put to use (something like myString("\D","_"), assuming that I need to replace all non-digit characters ), but it really did not help me getting the result.
    Would you spare some code for me reg. the usage of regular expressions in such a scenario?
    cheers,
    fun_one

  • Replace all occurrences of ENTER in a string

    Hi,
    I have a string which contains line breaks:
    '<HTML><HEAD>
    </HEAD>
    <BODY>'
    and it is shown to me in the debugger as:
    '<HTML><HEAD>#</HEAD>#<BODY>'
    Now I want to replace all line breaks in the string,
    but
    replace all occurrences of `#` in text with ' '.
    doesn't work.
    So if you have an idea how to replace the # symbol for Enter in a string please tell me ;).
    regards,
    Stefan

    Hi,
    Pls use
    replace all occurences of '#' in text with cl_abap_char_utilities=>newline.
    Eddy

  • Replace all ', , ' inside string

    i have long string and with pl/sql i want to replace all ', ,' with ', null,'.
    I can use replace function like:
    prepare_insert := replace(prepare_insert,', ,',', null,');
    but it will only replace first ', ,' not all. How can i replace all?

    5th database commandment:
    Thou shalt not create dynamic insert statements!
    I think using bind variables or the using clause in the execute immediate statement would solve the problem.
    But of cause you can do it also the hard (and slow) way.
    The problem is that your search string is not correct. It does include a leading "," and leaving ",". However if the leavaing "," is also the leading "," of the next replacement part then the function can't take this into account.
    Solution 1) Take care of this while building the string in the first place.
    While concating the pieces togeather use NVL(value,'null'). If you are sure that there s no value, then write NULL.
    Solution 2) Use a double replace
    with testdata as (select 'Test, , , , ''ABC''' txt from dual union all
                      select 'Test2, , , ''ABC''' txt from dual
    select txt
          ,replace(replace(txt,', ,',',null,'),', ,',',null,')
    from testdata;
    TXT               REPLACE
    Test, , , , 'ABC'     Test,null,null,null, 'ABC'
    Test2, , , 'ABC'     Test2,null,null, 'ABC'

  • Replaces all occurnces of one String with another String in a given source

    Hi all I had found that there is a lot of interest int this topic. there is a little piece of code that I wrote for myself recently, so I fgigured that it might be helpful for some...
    This method will scan through a string "source", find all of the occurances of a String "before" and replace them with the "after".
    Enjoy :-)
    public static String replace(String source, String before, String after)
    StringBuffer sb = new StringBuffer(source);
    int startpos = source.indexOf(before);
    int endpos = startpos + before.length();
    int i = startpos;
    while( i > -1 )
         if( startpos > -1 && endpos <= source.length() )
         source = sb.replace(startpos, endpos, after).toString();
         int lastReplace = source.lastIndexOf(after) + after.length();
         if(lastReplace <= source.length())
              startpos = source.substring(lastReplace, source.length() ).indexOf(before);
                   endpos = startpos + before.length();
                   i = startpos;
         else
              i = source.length();
         else
              i = -1;
    return source;
    Oh yeah if you want, you can visit my site http://www.infobrokery.com it is where this code is used to replace the text URL with html.

    Since 1.4 the String class has a replaceAll method ...

  • Program for find and replace a string in all the reports in a package

    Hello experts,
                        Is there any standard report or transaction provided by SAP which can be used to find a String in all the program in a package ? 
    As per my knowledge there is a program RPR_ABAP_SOURCE_SCAN which can search for a string in a package but this program doesnot support the replacement .
    Any clue in this regard will be helpful.
    Thanks
    Vivek

    Vevek, you are searching for something very very destructive.. do you realize that?
    its better if you could explain us the requirement, by the way for a automated change you need to have INSERT REPORT called inside some program, so start searching that line if you can get it
    else, write a piece of code for it..

  • How to use String.replaceAll(String regex, String replacement)?

    hi,
    I'd like to use the String.replaceAll call to replace all occurrences of a pattern in a string with a string inputted from the user.
    The problem is that replaceAll seems process the replacement string first. For example, the code below won't work
    public class StringTest {
         public static void main(String [] arg) throws Exception {
              String input = "oooIoooIooo";
              input=input.replaceAll("I","\\");
              System.out.println(input);
    }So the only option seems to be to manually process the user input string into a form that can be accepted by String.replaceAll?
    The only thing I can find from looking through the API is that you'd need to convert each backslash to a double-backslash?
    is this the right thing to be doing?
    thanks,
    asjf

    just to clarify, at the moment I think the solution is to do this
    public class StringTest {
         public static void main(String [] arg) throws Exception {
              String input = "oooIoooIooo";
              String raw = "\\";
              input=input.replaceAll("I",raw.replaceAll("\\\\","\\\\\\\\"));
              System.out.println(input);
    }

  • Replacing all " into \" in a string.

    I have a huge string which contains ". I have to change all the " into \". I tried the String.replace( ) but not sure how to make it work. I need that special escape character to specify for the replacement. Please help.....

    Try replaceAll( string, string).Not quite so simple as implied by this. The first parameter is a regular expression and the second is related to a regular expression. What you need is
                String aNotSoHugeString = "jlk\"fal auf\"ha fi\nhfaj\"hflkj ljkfh jfa\"ljf\n";
                String updatedNotSoHugeString = aNotSoHugeString.replaceAll("\"","\\\\\"");To understand more check out java.util.regex.Pattern.
    :-( One day I might catch up with the rest of the world!
    Message was edited by:
    sabre150

  • How use replace all grid row with variable value

    hi master
    sir i have master detail form
    in detail form i have 5 column grid thate have 25 row at time
    one column name id
    such as id have value 23
    but i want replace all id row with 555
    how i replace all id in grid with 555 befor commit_form
    how i use loop for grid
    or any other method
    please give me idea
    thank's
    aamir

    Go_Block('Detail');
    First_Record;
    Loop
      :detail.item := '...' ;
      Exit when :system.last_Record = 'TRUE' ;
      Next_record;
    End loop;
    First_Record ;Francois

  • Replace all in a string

    Hello,
    I need to replace all occurences of
    <image>url to a image goes here</image>
    to
    <img src="url to a image goes here"/>
    where "url to a image goes here" is a url to an image
    Could you let me know how the call to replaceAll method will look like?
    Thank you.

           line = line.replaceAll("<image>([^<]*)</image>", "<img src=\"$1\"/>");

  • Has anyone experienced an unintended "find/replace all" in a document (using FM11) ?

    Hi All,
    Using FM11 with Windows7.
    We have a problem with the following:
    If I have completed a Find/Change All in Document A (then close the Find window), then I open Document B and press Control-F to perform a new search, once I start typing the previous word search/change all is applied to Document B when it's not the intention.
    The problem is when Control-F is pressed the last function is highlighted (in this case "Change All") - rather than the word field, so nothing is actually being typed in this field - rather it performs the last function.  The basic work-around is just to make sure we click or tab to the desired field before typing...  OR make sure to delete the previous find/change text fields before closing the window.  When doing things quickly though we may forget - so it gets annoying when we have to fix this or revert to last saved document.
    Users with XP don't experience this. Each time control-F is pressed, the Find term field is the highlight so the new term is typed in as expected.
    Any tips would be welcome. 
    Thank you,
    Tina

    Tina,
    There's been a change in behaviour with FM11's Find/Change (as you've noticed). The dialog now retains focus after a search has been performed and is modal. However, the focus of the field for ctrl-F should place it in the Text area, regardless of platform, not execute the last operation. This is buggy behaviour and I just confirmed this on my platform (regardless of whether your in Doc A or B).
    Please file a bug report at the FrameMaker Bugs & Wish List  (https://www.adobe.com/cfusion/mmform/index.cfm?name=wishform&product=63)

  • Search and replace all spaces between quotes with uderscore

    Hello,
    I'm new on Powershell and I'm trying to make the script that:
    searches over file and replaces all the spaces which have been found between quotes;
    removes all quotes (except these which has not value eg "").
    For example:
    Source file:
    string3=string4 string="string1 string2 string23" string8="" string5="string7 string8"
    Destination file:
    string3=string4 string=string1_string2_string23 string8="" string5=string7_string8
    I have been created script that searches the data correctly
    $file="c:\scripts\mk.txt"
    $data=Get-Content $file
    $1
    $regex = [regex]@'
    (?x) # ignore pattern whitespace option
    (?<test>(["'])(?:(?=(\\?))\2.)*?\1)
    $data |% {
    if ($_ -match $regex){
    new-object psobject -property @{
    test = $matches['test']
    }#when adding "|select-object test" I'm getting the correct data
    I have stopped here on search / replace operation (from space to underscore, and by removing the quotes leaving the empty quotes non touched). Can you help me to finish the script?
    Thanks!

    Try this.  It uses the [Regex] Replace static method, with a script block delegate:
    $file="c:\scripts\mk.txt"
    $data=Get-Content $file
    $regex = '(\S+=[^"\s]+)|(\S+="[^"]+")'
    $delegate = { $args[0].value.replace(' ','_') -replace '"(.+)"','$1' }
    $data |% { [regex]::Replace($_,$regex,$delegate) }
    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "

Maybe you are looking for

  • Are ATI graphics issues fixed in Leopard 10.5.1 -- ?

    I haven't downloaded 10.5.1 yet and installed it on either of my machines. Can anyone with an ATI card (preferably a 9600, X1900 or X800 XT) confirm that the graphics issues we've identified in previous threads, have been fixed? Please do tell.

  • How to set up standalone wireless print server

    I need step-by-step instructions on to set up a KonicaMinolta bizhub multifunction printer to print wirelessly from various Macs. In other words, it would not be hooked up to the internet or my wireless network. I understand this can be done with an

  • How to specify a date in a method signature

    How do I specify a date as a method parameter of a bean that will be used to generate a SOAP service? If I specify java.util.Date, I get NullPointerExceptions, perhaps because the internal structure of Date is not compatible with SOAP supported types

  • SQL Developer 4.0.0.13.80-no-jre.zip

    So I want to run SQL Developer on a Solaris 10 x86 platform and i've got JDK 1.7.0_51 installed. I downloaded the platform agnostic bundle with no JRE, and extracted the zip file. It appears that none of the shell scripts have the correct permissions

  • Credit check urgent

    hello to every one, sub:- credit limit is working, but terms of payment is not working.   Requriment :- credit management, system is to be consider the terms of payment and credit limit for the customer if custome fails to pay the billing amount with