Regular Expression / replace Function Help

The problem:
cfset myString = "i am a big boy"
cfset outputString = replace("i am a big
boy","i","you","all")
Wrong Output:
you am a byoug boy
Intended Output
you am a big boy
How do I achive that output.

Your first example had only one sentence. That's why I gave
that answer.
Anyway for your real question, you need to use regular
expressions
#rereplace(myString,"i\s","you ","all")# - will give u
you am a big boy you am a big boy you am a big boy you am a
big boy.
\s looks for a whitespace character after the letter i. So
that way it will not change the letter i in big

Similar Messages

  • Regular Expression/Replace - Oracle 7.3

    Hi!
    I am trying the regular expression SQL functions of 10g to Oracle 7.3 and it seems the older version does not cover this feature yet.
    "Aaaa,Bbbb" --> "Aaaa, Bbbb"
    REPLACE *",[0-9A-Za-z]"* WITH *", "*
    The string pattern is to look for comma-punctuations that is not followed immediately by whitespacess so I can replace this with a comma followed by a whitespace.
    Any workaround for this?

    Hi,
    Welcome to the forum!
    kitsune wrote:
    Hi!
    I am trying the regular expression SQL functions of 10g to Oracle 7.3 and it seems the older version does not cover this feature yet.You're right; regular expressions only work in Oracle 10.1 and higher.
    >
    >
    "Aaaa,Bbbb" --> "Aaaa, Bbbb"
    REPLACE *",[0-9A-Za-z]"* WITH *", "*
    The string pattern is to look for comma-punctuations that is not followed immediately by whitespacess so I can replace this with a comma followed by a whitespace.
    Any workaround for this?You're best bet in Oracle 7.3 would be a user-defined function. That's a very old version; don't expect much.
    Do you know anything else about the string? For example, is there some character (say ~) that never occurs in the string? Will there ever be two (or more) whitespace characters after punctuation? What characters do you consider to be whitespace? Which are punctuation? Depending on the answers, you might be able to do something with nested REPLACE and/or TRANSLATE functions.

  • Replace function help

    Hi all, sry for post sql problens in APEX forum, but i realy need help for this...
    I´m trying to replace : for , to make a select where in () with more then one value... but the replace function its not work with more then 1 value...
    like this
    select name from vw_requerente where id_cliente in REPLACE(:P5000_CLIENTE,':',',')in that item has this value: 71:72:73 , but all i get is a ORA: INVALID NUMBER, how can i make a replace function to work with this?
    tnks alot and sry my english.

    He also posted this in the pl/sql forum and received some good advice there:
    replace function help
    Especially the tom kyte blog portion:
    [http://tkyte.blogspot.com/2006/06/varying-in-lists.html]
    Thank you,
    Tony Miller
    Webster, TX

  • Regular Expressions - replace inner group

    I'm trying to do the following:
    1. Given the following string:
    Truth, like tumors, require a cut to be removed.
    2. Grab the whole sentence and the following:
    like tumors
    3. Replace "like tumors" with "like posion" and add one line to the sentence like so:
    Truth, like posion, require a cut to be removed.
    To be free you must endure pain for a season to finally be free from it.
    I can grab the sentence with reg expressions, I can even grab the second search (#2) in a group, I'm just wondering if there is an elegant way to replace both at the same time. I could always replace one then search and replace the next, but that seems redundant since I can grab both the first time around. Any help?

    according to:
    http://javaalmanac.com/egs/java.util.regex/GroupInRep.html?l=find
    // Compile regular expression
    String patternStr = "\\((\\w+)\\)";
    String replaceStr = "<$1>";
    Pattern pattern = Pattern.compile(patternStr);
    // Replace all (\w+) with <$1>
    CharSequence inputStr = "a (b c) d (ef) g";
    Matcher matcher = pattern.matcher(inputStr);
    String output = matcher.replaceAll(replaceStr);
    // a (b c) d <ef> gthis should be exactly what you're looking for.

  • Regular expression - Replace not like

    Hi All,
    Is there a regexp pattern to replace anything other than 'oracle' from the below string.
    "oracle sdsd oracle xyd fgh oracle idmdh asasas trtrt"
    The result will be "oracleoracleoracle"
    If I want to write like regexp_replace('oracle sdsd oracle xyd fgh oracle idmdh asasas trtrt',<pattern>), what should be the pattern?
    I know how to get the result by nesting regexp and other functions.
    But is there any single pattern for this?
    Thanks in advance.
    Note; This is not a business requirement, trying to learn regexp..

    884476 wrote:
    Could you please explain what does that pattern mean? We can look at your string as a sequence of substrings where each substring is set of characters (part A) followed by word oracle or, in last substring, by end-of-line (part B). Each of such substrings be want to replace with part B thus removing part A.
    Dot (.) means any character. Asterisk (*) means repeated 0 or more times. This is our part A (I'll get back to ? later). Pipe (|) means OR. Dollar sigh ($) means end-of-line. Parenthesis mean grouping. So ((oracle)|$) means string oracle or end-of line. This is our part B. Now back to question mark. By default Oracle regular expressions are "greedy". We say any character repeated any number of times followed by word oracle. Since word oracle itself matched definition of any character repeated any number of times (6 in this case) regexp will match it that way that it will be from the beginning of the string to last occurrence of word oracle - that's why it is called "greedy". Question mark (?) tells regexp not to use greedy matching, therefore '.*?oracle' will stop at first occurrence of word oracle. Now replacement string. Notation \1 is grouping backreference. Group 1 is ((oracle)|$) and, as I already noted, means string oracle or end-of line (whichever was found).
    SY.

  • Regular Expression replacement not working

    I am trying to use a regular expression to replace non-ascii characters on a file, and I'm afraid I've reached the end of my regex knowledge. 
    Here is the specific code
    'Set the Regular Expression paramaters
    Set RegEx = CreateObject("VBScript.Regexp")
    RegEx.Global = True
    RegEx.Pattern = "[^\u0000-\u007F]"
    RegEx.IgnoreCase = True
    'Replace the UTF-8 characters
    ReplacedText = RegEx.Replace(FileText, "\u0020")
    If I understand regular expressions correctly the pattern of "[^\u0000-\u007F]" should replace any character that is not an ascii character, and then replace it with a space (which I understand is "\u0020").  What am I doing wrong?

    Simply use
    ReplacedText = RegEx.Replace(FileText, " ")
    Regards, Hans Vogelaar (http://www.eileenslounge.com)

  • OWA_PATTERN regular expressions CHANGE function

    Hello,
    I'm trying to use the CHANGE function to match an expression and then change the matched part of the string. The twist is that I would like to pass the matched part of the string through a function before it is replaced in the original string. Here is an example:
    Pattern: 'C'
    Text: 'CAAACAAAC'
    Resulting text: 'DAAADAAAD'
    Where the 'D' is the result of calling a function. The actual call to the OWA_PATTERN.CHANGE looks something like this:
    OWA_PATTERN.CHANGE(mytext,'C',myfunction(&))
    where the & argument to myfunction is as specified in the ORACLE docs as a reference to what was matched. The line of code doesn't work however. Anyone ever done anything like this?
    Aziz 8)

    SQL> CREATE OR REPLACE FUNCTION myfunction
      2    (p_pattern IN VARCHAR2)
      3    RETURN      VARCHAR2
      4  AS
      5  BEGIN
      6    RETURN CHR (ASCII (p_pattern) + 1);
      7  END myfunction;
      8  /
    Function created.
    SQL> CREATE OR REPLACE PROCEDURE test_pattern
      2    (pattern IN VARCHAR2,
      3     text    IN VARCHAR2)
      4  AS
      5    mytext      VARCHAR2 (256);
      6  BEGIN
      7    mytext := text;
      8    owa_pattern.change (mytext, pattern, myfunction (pattern), 'g');
      9    DBMS_OUTPUT.PUT_LINE ('Pattern:         ' || pattern);
    10    DBMS_OUTPUT.PUT_LINE ('Text:            ' || text);
    11    DBMS_OUTPUT.PUT_LINE ('Resulting text:  ' || mytext);
    12  END test_pattern;
    13  /
    Procedure created.
    SQL> SET SERVEROUTPUT ON
    SQL> EXECUTE test_pattern ('C', 'CAAACAAAC')
    Pattern:         C
    Text:            CAAACAAAC
    Resulting text:  DAAADAAAD
    PL/SQL procedure successfully completed.

  • How to use regular expression replace for this special characters?

    hi,
    I need to replace the below string, but i couldnt able to do if we use the special charaters '+', '$' . can anyone suggest a way to do this?
    select REGEXP_REPLACE('jan + feb 2008','jan + feb 2008', 'feb',1,0,'i') from dual
    anwers should be :- feb

    you should use escape character \.
    the regular expression will look like as follows:
    select REGEXP_REPLACE('jan + feb 2008','jan \+ feb 2008', 'feb',1,0,'i') from dual
    hope this is what you needed.
    cheers,
    Davide

  • Regular expression - Replace a part of an expression

    Dear All,
    This is not a business requirement, just trying to practice regexp.
    Suppose we want to replace a part of a regular expression from a string. As an example, in the string 'THIS Number 124356 Is to Change.This Number 5 Also', I am trying to replace the last digit of each number with $ sign.
    Output will be
    'THIS Number 12435$ Is to Change.This Number $ Also'.
    Will this be possible using a single regexp_replce?
    Thanks in advance.

    MichaelS wrote:
    I am trying to achieve this using a SINGLE regexp_replace.Here we go:
    SQL> with t as (
    select 'ABC124556def568gh236klJ258' str from dual union all
    select 'THIS Number 124356 Is to Change.This Number 5 Also' str from dual
    select str, regexp_replace(str, '(\d{0,})\d{1}', '\1$') str2
    from t
    STR                                                     STR2                                                  
    ABC124556def568gh236klJ258                              ABC12455$def56$gh23$klJ25$                            
    THIS Number 124356 Is to Change.This Number 5 Also      THIS Number 12435$ Is to Change.This Number $ Also    
    2 rows selected.
    Nice..
    Learning for me ..
    Never thought of usage like {0,} ... kepping the end value OPEN.
    I was trying with \d+?\d, which was not working..

  • Regular Expression "Replace"

    (<PartName>([a-z]))(.*)(</PartName>)
    I need to change all copy within the <PartName></PartName> tags with Sentence Case. Above selects all the copy that doesn't have a capital.
    To write the above out in find and repalce, I would just use $1$2$3$4 but I need the $2 to be a Capital.
    What's crazy is that this would seem to be a fairly common thing to do yet finding an answer is nearly impossible. I even have OReilly's Regular Expression Cookbook book and there's nothing in it about replacing text with changed text.
    I've been on this for a day now and it's getting to the point where I could have gone through and done it manually in less time.
    Sorry for the rant...

    I gave up and just exported out from my xml into Excel and did a formula there...

  • Regular Expressions (Pattern/Matcher) --- Help

    Hi,
    I have an regex i.e. Pattern.compile("([0-9])D([0-9])'?(?:([0-9]+)\")?([NSEW])").{code}
    It has to exactly match the input e.g *45D15'34"N*
    I need to retrieve the values based on grouping.
    Group1 = 45 (degree value)
    Group2 = 15 (minutes value)
    Group3 = 34 (seconds value) ----> this is a non-capturing group
    Group4 = N (directions)
    The regex works fine for most of longitude/latitude value but I get a StackOverFlow for some. There is a known bug on this http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5050507
    According to the bug report, they have said that are many different regex that can trigger the stack overflow....even though the length of my input is not as long as the one posted on the bug report.
    I was wondering if anyone could suggest a different way of writing the regex above to avoid the stack over flow.
    Thank you in advance                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    Hi,
    I missed the '+' in my original regex Pattern.compile("([0-9]+)D([0-9]+)'?(?:([0-9]+)\")?([NSEW])"){code}.
    I have also tried {code} Pattern.compile("(\\d+)D(\\d+)'?(?:(\\d+)\")?([NSEW])");And, the other 2 expressions as suggested by you.
    The problem happens when Durham Lat=”35D52’N” Lon=”78D47’W value is selected from a Jtree(the values are parsed from a xml file to the tree - the xml file has a bout 800 longitude/latitude elements for different cities in the US). It does not happen for other values and If I increment the degree or min by, then the expression works. I am not sure how else i could re-write this exp.
    Below is the snippet of the xml file:
    <State name="NORTH CAROLINA">
                <City name="Asheville AP"     Lat="35D26'N"     Lon="82D32'W"/>
                <City name="Charlotte AP"     Lat="35D13'N"     Lon="80D56'W"/>
                <City name="Durham"     Lat="35D52'N"     Lon="78D47'W"/>
                <City name="Elizabeth City AP"     Lat="36D16'N"     Lon="76D11'W"/>
                <City name="Fayetteville, Pope AFB" Lat="35D10'N"     Lon="79D01'W"/>
                <City name="Goldsboro,Seymour-Johnson"     Lat="35D20'N"     Lon="77D58'W"/>
                <City name="Greensboro AP (S)"     Lat="36D05'N"     Lon="79D57'W"/>
                <City name="Greenville"     Lat="35D37'N"     Lon="77D25'W"/>
                <City name="Henderson"     Lat="36D22'N"     Lon="78D25'W"/>
                <City name="Hickory"     Lat="35D45'N"     Lon="81D23'W"/>
                <City name="Jacksonville"     Lat="34D50'N"     Lon="77D37'W"/>
                <City name="Lumberton"     Lat="34D37'N"     Lon="79D04'W"/>
                <City name="New Bern AP"     Lat="35D05'N"     Lon="77D03'W"/>
                <City name="Raleigh/Durham AP (S)"     Lat="35D52'N"     Lon="78D47'W"/>
                <City name="Rocky Mount"     Lat="35D58'N"     Lon="77D48'W"/>
                <City name="Wilmington AP"     Lat="34D16'N"     Lon="77D55'W"/>
                <City name="Winston-Salem AP"     Lat="36D08'N"     Lon="80D13'W"/>
            </State>
    public final class GeoLine {
        /* Enum for the possible directions of longitude and latitude*/
        public enum Direction {
            N, S, E, W;
            public boolean isLongitude() {
                return (this == E || this == W);
            public boolean isLatitude() {
                return (this == N || this == S);
            public Direction getCanonicalDirection() {
                if (this == S) {
                    return Direction.N;
                } else if (this == W) {
                    return Direction.E;
                } else {
                    return this;
        private final int degree;
        private final int minute;
        private final int second;
        private final Direction dir;
        /* Recognizes longitude and latitude values that has degrees, minutes and seconds i.e. "45D15'34"N
        * or "45D1534"N. The single-quotes for the minutes is optional. And, for the moment we do not support seconds
        * validation although ilog library returns the longitude/latitude with second when NEs and Sub-networks are
        * dragged and dropped on the map.*/
    private static final Pattern PATTERN = Pattern.compile("([0-9]+)D([0-9]+)'?(?:([0-9]+)\")?([NSEW])");
        public GeoLine(int degree, int minute, Direction dir) {
            this(degree, minute, 0, dir);
        public GeoLine(int degree, int minute, int second, Direction dir) {
            Log.logInfo(getClass().getSimpleName(), "PAU degree: " + degree + " minute: " + minute + " second: " + second + " direction: " +  dir);
            verifyLongitudeLatitude(degree, dir);
            verifyMinute(degree, minute, dir);   
            this.degree = degree;
            this.minute = minute;
            this.second = second;
            if (this.degree == 0 && this.minute == 0 && this.second == 0) {
                this.dir = dir.getCanonicalDirection();
            } else {
                this.dir = dir;
        public Direction getDirection() {
            return dir;
        public int getMinute() {
            return minute;
        public int getDegree() {
            return degree;
        public int getSecond() {
            return second;
        public static GeoLine parseLine(String location) {
            * Matcher class will throw java.lang.NullPointerException if a null location
            *  is passed, null location validation is not needed.
            Matcher m = PATTERN.matcher(location);
            if(m.matches()) {
                int deg;
                int min;
                int second;
                Direction direction;
                deg = Integer.parseInt(m.group(1));
                min = Integer.parseInt(m.group(2));
                if (m.group(3) == null) {
                    second = 0;
                } else {
                    second = Integer.parseInt(m.group(3));
                direction = Direction.valueOf(m.group(4));
                return new GeoLine(deg, min, second, direction);
            } else {
                throw new IllegalArgumentException("Invalid location value. Expected format XXDXX'XX\"[NSEW] " + location);
        private void verifyMinute(int deg, int min, Direction direction) {
            /* This validation is to make sure that minute does not exceed 0 if maximum value for latitude == 90
            * or longitude == 180 is specified */
            int maxDeg = direction.isLatitude() ? 90 : 180;
            if(min < 0 || min > 59) {
               throw new NumberFormatException("Minutes is out of range. Value should be less than 60: " + min);
            if (deg == maxDeg && min > 0) {
                throw new NumberFormatException("Degree value " + deg + "D" + direction + " cannot have minute exceeding 0: " + min);
        private void verifyLongitudeLatitude(int valDeg, Direction valDir) {
               int max = valDir.isLatitude() ? 90 : 180;
               if(valDeg < 0 || valDeg > max) {
                    throw new NumberFormatException("Degree " + valDeg + valDir + " is invalid");
        public final boolean isLongitude() {
            return dir.isLongitude();
        public final boolean isLatitude() {
            return dir.isLatitude();
        @Override
        public final String toString(){
            if(minute < 10){
                return degree + "D0" + minute + dir;
            } else {
                return degree + "D" + minute + dir;
        @Override
        public boolean equals(Object obj) {
            if (obj instanceof GeoLine) {
                GeoLine other = (GeoLine) obj;          
                    return (this.degree == other.degree && this.minute == other.minute && this.second == other.second && this.dir == other.dir);
            return false;
        @Override
        public int hashCode() {
            int result = 17;
            result = result * 37 + degree;
            result = result * 37 + minute;
            result = result * 37 + second;
            result = result * 37 + dir.hashCode();
            return result;
    }Thank you again.

  • Regular expression problem - pls help

    I would love to have a reg exp that checks for:
    a-z
    +0-9+
    +'_'+ as well as +'-'+
    as well as the DOT character.
    How can this happen ?
    I have tried both:
    [a-z0-9_-\\Q.\\E]+as well as
    [a-z0-9_-\\.]+and I am given:
    java.util.regex.PatternSyntaxException: Illegal character range near index 10
    [a-z0-9_-\Q.\E]+Please help
    Thank you

    javaUserMuser wrote:
    No, because it is not a metacharacter as defined by the Pattern javadoc.
    What's going on still remains a mystery to me as of now.???
    but it has very definite meaning as the range operator when used in a regex, and the strange thing is that you use it yourself in this defined meaning:
    [a-z0-9_-\\Q.\\E]+{code}
    How can you see that it doesn't need to be escaped when here you use - to show the range for letters and numbers: a-z and 0-9?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Regular Expression Replacement

    I have a replacement string of the form "[\1\2]='\3'," and
    I'd like to insert a carriage at the end of the string. I've tried
    \n, \r\n and it doesn't seem to work.

    jdeline wrote:
    > Chr(10) is newline, Chr(13) is carriage return. BTW, do
    we all know what a carriage is? :-)
    sure! it's a 4-wheel horse-drawn transportation device!
    apparently it
    can be returned... presumably if you do not want it any more
    or if it
    has become outdated... anyone knows WHERE they are returned
    to? :)
    Azadi Saryev
    Sabai-dee.com
    Vientiane, Laos
    http://www.sabai-dee.com

  • What  is regular expression search function

    hi
    what is use CHARTOROWID ,COMPOSE fuction in oracle

    http://download.oracle.com/docs/cd/E11882_01/server.112/e17118/functions025.htm#SQLRF00615
    http://download.oracle.com/docs/cd/E11882_01/server.112/e17118/functions032.htm#SQLRF00618

  • I need help renaming a file using regular expressions in Bridge.

    Hi,
    I work at a university, and we are working through files for our Thesis and Dissertations. We have been renaming them to make them more consistent. I am just wondering if there is a regular expression that could help with this process?
    Here is come examples of current file names;
    THESIS 1981 H343G
    Thesis 1981 g996e
    THESIS-1981-A543G
    I don't need to change the actual names of the files. just how they are formatted.
    Proper case on Thesis.
    Hyphens(-) in all white space.
    First letter capital, last letter lowercase on the call no (H343g)
    So the list above should look like;
    Thesis-1981-H343g
    Thesis-1981-G996e
    Thesis-1981-A543g
    I have seen people do some pretty cool things with regular expressions! Any help would be greatly appreciated. Thanks!

    You would be better off using a script to do this as an example as I don't think it would be possible in the Bridge re-name.
    Using ExtendScript Toolkit or a Plain text editor copy the code into either and save it out as Filename.jsx
    This needs to be saved into the correct folder. this is found by going to the preferences in Bridge, selecting Startup Scripts, this will open the folder where the script is to be saved.
    Once this is done close and re-start Bridge.
    To Use: Goto the Tools Menu and select Rename PDFs
    Make sure you test the code with a few copied files into a seperate folder first to make sure it does what you want.
    The script will do all PDF files in the selected folder.
    #target bridge 
    if( BridgeTalk.appName == "bridge" ) { 
    renamePDFs = MenuElement.create("command", "Rename PDFs", "at the end of Tools");
    renamePDFs.onSelect = function () {
    app.document.deselectAll();
    var thumbs = app.document.getSelection("pdf");
    for( var z in thumbs){
    var Name = decodeURI(thumbs[z].spec.name);
    var parts = Name.toLowerCase().replace(/\s/g,'-').match(/(.*)(-)(.*)(-)(.*)(\.pdf)/);
    var NewName = parts[1].replace(/^[a-z]/, function(s){ return s.toUpperCase() });
    NewName += parts[2]+parts[3]+parts[4]+parts[5].toUpperCase().replace(/[A-Z]$/, function(s){ return s.toLowerCase() });
    NewName += parts[6];
    thumbs[z].spec.rename(NewName);

Maybe you are looking for

  • InDesign Suddenly Not Recognizing Serial Number

    I have CS2, which I installed right after I bought the Intel Mac, 3 years ago. Was able to enter the Photoshop serial number that it wanted at that time, but I have since lost or misplaced the folder that had all my Adobe registration info. I have th

  • Sap Script Queries

    Hi Experts, I need to print Long Text maintained for a record in sap. I have the Text ID and Text Object but don't know about the Text Name and I have to print this Long Text in my SAP SCRIPT to be shown on the Form and i am not doing changes in stan

  • ISE 1.3 Error

     I got an issue after upgrade. When I click on external identity sources, then on AD .. the page will freeze and keeps with a message "Loading page..." and never finishes

  • HowTo find item usage in existing reports

    Hello, I would like to cleanup an existing and grown universe. I went to hiding the fields/Items I'm planning to remove. Furthermore I would like to check, whether these "deprecated" fields/items are still being used in any report, before removing th

  • If an employee changes Company code,how his YTD cumulations in CRT table calculates as per SAP Standards ?

    Hi All, Please help me out in understanding below scenario. If an employee changes from one company code to another code, how his/her YTD cumulates in CRT table as per SAP Standards. Let me go with example to make a clear understanding. Ex : Payroll