Regular Expression Issue

Dear Gurus,
I had a requirement to read a file and display the words btween two words..
for an example..
I need a good friend to share my sarrow things. I need a good friend to share my Loveable things.
here i need to extract words between good and Loveable
for this i wrote an regular expression
Pattern p = Pattern.compile("(?<=\\bgood\\b).*?(?=\\bloveable)\\b)");this is working fine
Now I need to extract the words between good and loveable or sarrow
I read from regex tutorial to use | symbol for OR operations.
Can any one help to solve this issue.
Thanks and Regards,
Durai S E
Edited by: user10734545 on Dec 12, 2011 12:30 AM
Edited by: EJP on 12/12/2011 19:30: code tags

user10734545 wrote:
for this i wrote an regular expression
Pattern p = Pattern.compile("(?<=\\bgood\\b).*?(?=\\bloveable)\\b)");
Sometimes a simple solutions is best:  @Test
    public void testGoodLovable() throws Exception {
        Pattern pattern = Pattern.compile("good\\s+(\\w+)\\s+lovable");
        Matcher matcher = pattern.matcher("good test lovable");
        if (matcher.find()) {
            Assert.assertEquals("test", matcher.group(1));
        } else {
            Assert.fail("pattern not matched");
    }bye
TPD

Similar Messages

  • Pattern regular expression issue

    I am trying to validate the file names , the file names can be alpha numeric and can have '_' '-''.' symbols alone
    my code dunno why but my pattern does not work for test# file name
    Pattern _namePattern = Pattern.compile("^\\w\\s-//.]+$");
    private boolean validateFilename(String name) {
              boolean valid = true;
              if (this._namePattern != null) {
                   valid = !(this._namePattern.matcher(name).matches());
              if (valid) {
                   valid = (name.indexOf("%2f") < 0) && (name.indexOf(58) < 0);
              return valid;
         private boolean validateFilenames(File files) {
              if (this._namePattern == null) {
                   return true;
              boolean valid = true;
              if (!(validateFilename(files.getName()))) {
                   System.out.println("ERROR.INVALID_FILENAME"
                             + "The following file contains invalid characters: "
                             + files.getName());
                   valid = false;
              } else {
                   System.out.println("Valid file name " + files.getName());
              return valid;
         }

    i have gone through this link its the same as the pattern API the problem is i have tried so many expressions now that i have lost all of it :(
    Ram asked:
    What was the input string you used to test the above expression?i tried with test it fails for expression [\\w._-]+$so i used negate sight as i am doing a inverse logic in the code and it worked for test
    [^\\w._-]+$now if i tested with a tes#t it still shows a valid string which is not correct
    with the space literal it works for strings having spaces but when i have a input test #test it fails
    I might be sounding too stupid but the matching logic is already present in a third party jar code i don't want to change the logic which i posted in my first i just want to change the regular expression so that it does not allow file names with any of the special characters

  • Javascript regular expression issue

    Hi,
    I am trying to use a javascript regular expression in my code
    var reg_exp = new RegExp("^([0-9]{2})/([0-9]{2})/([0-9]{4})\s([0-9]{2})$");it works from outside of APEX but not being called from inside APEX. It is failing on the
    \sIs there some override or some reason why I cannot do this from inside APEX?
    Thanks in advance!

    Well I just changed it to
      var reg_exp = new RegExp("^([0-9]{2})/([0-9]{2})/([0-9]{4}) ([0-9]{2}):([0-9]{2})$");basically just replaced an actual space for \s and it works fine...

  • Range & Regular Expression issue.

    I'm having a bit of trouble and I'm close to head butting a wall. It's a logic problem. I am trying to create a class, when given a range e.g., 52 - 234 it will output the regular expression
    [5][2-9] | [6-9][0-9] | [1][0-9][0-9] | [2][0-2][0-9] | [2][3][0-4]
    another example
    12-23
    [1][2-9] | [2][0-3]
    It's giving me a logic headache. I can't help but walk around thinking in for loops after trying to get this to work. However, I noticed that someone on the Internet has made a Java tool that does exactly this, but all their links are dead :o(
    Anyone got any ideas? Seen this before? Done this yourself? Help? I've been at this for days now, and I'm fed up!
    Thanks :o)

    Two things:
    1. To use quote inside quoted string you must put two quotes in a row.
    2. Certain characters have special meaning in regeular expressions. You must escape them with \ if you do not want regexp to interpret such characters.
    Select regexp_replace('kathu&+','[/.#''& "\\-\+]')from dual;
    REGEX
    kathu
    SQL>
    {code}
    SY.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Oracle Regular expression issue

    Hi All,
    I have regular expression problem.
    create table url ( Url varchar2(1024));
    insert into URL values ('http://abc.jambo.com/ababs/sffef/dsf/sdfdsf/jk.htm')
    insert into URL values ('.*amazon.com.*');
    insert into URL values ('Abc.com');
    insert into URL values ('xyz.Abc.com');
    insert into URL values ('^http://bhido.jambo.com/ababs/kd.htm     ');
    commit
    SELECT url,REGEXP_SUBSTR(url,'http://([[:alnum:]]+\.?){3,4}/?') "REGEXP_SUBSTR"
    FROM url
    But it returns following result
    URL                                                                       REGEXP_SUBSTR
    http://abc.jambo.com/ababs/sffef/dsf/sdfdsf/jk.htm         http://abc.jambo.com/
    .**abc.amazon.com.**                                                 NULL
    Abc.com                                                                 NULL
    xyz.Abc.com                                                         NULL
    .**amazon.com.**                                                         NULL
    ^http://bhido.jambo.com/ababs/kd.htm                         http://bhido.jambo.com/
    *What changes would be required in RegEx to get following output*
    *URL                                                                       REGEXP_SUBSTR*
    http://abc.jambo.com/ababs/sffef/dsf/sdfdsf/jk.htm         abc.jambo.com
    .**abc.amazon.com.**                                                 abc.amazon.com
    Abc.com                                                                 Abc.com
    xyz.Abc.com                                                         xyz.Abc.com
    .**amazon.com.**                                                         amazon.com
    ^http://bhido.jambo.com/ababs/kd.htm                         bhido.jambo.comThanks in advance
    -Kuldeep
    Edited by: Kuldeep2 on Apr 28, 2009 3:56 AM
    Edited by: Kuldeep2 on Apr 29, 2009 3:28 AM

    SQL> select url, regexp_substr(url,'[[:alnum:]|\.]*com')new_url from url
      2  /
    URL                                                NEW_URL
    http://abc.jambo.com/ababs/sffef/dsf/sdfdsf/jk.htm abc.jambo.com
    .*amazon.com.*                                     amazon.com
    Abc.com                                            Abc.com
    xyz.Abc.com                                        xyz.Abc.com
    ^http://bhido.jambo.com/ababs/kd.htm               bhido.jambo.com

  • [solved]Issue concerning regular expressions

    Perhaps the problem in it's entirety is a bit more involved that just regular expressions, but for a start, this small problem is what I need help with.
    In short, I have some data which can be in the of some text, an IP address or an URL.
    In case that it's URL, it will usually, if not always, be in the form of a base URL, with or without one or more subdomains.
    I need to strip away these sub domains so that only the base URL remain, thus:
    abc.def.ghi.com
    becomes
    ghi.com
    forgetting for the moment that some top level domains have two parts, it seems so easy, yes I cannot for the life of me figure out how to do it, using only the basic command line tool available such as sed, awk, and so on and so forth, and thus I hope that someone here can and will help me. It is of course also possible that the process is simply to involved that a simple command line will do, in which case I suppose a bahs or python script will have to do, but I really hope not. In any case I will appreciate any help and/or advise you can give me.
    Best regards.
    Last edited by zacariaz (2015-05-07 13:38:47)

    WorMzy wrote:
    Is this a homework exercise?
    What have you tried so far? It should be easy enough to accomplish using a combination of rev and cut, although I'm sure there are more elegant solutions using awk.
    Mod note: Moving to Newbie Corner
    I wish it were homework, but no.
    The rev idea is interesting, and I'll look into it, but as it is, an awk solution would be preferable, as this is only part of a larger issue, and I'd like to keep it as simple as possible. Also, as for topdomain with two parts, it's still somewhat involved.
    As for what I've tried, a lot as I only stopped and went to bed when I realized the sun was raising, but the main problem is that I don't really know how to attack the problem, and of course I'm not exactly a master of regular expressions.
    Anyway thanks.

  • PrintWriter issue with Directory Traversal and Regular Expression

    This is a follow up to my previous question on the forum. I am developing a program traverses the hard drive for information. If it finds the said information in any of the file (based on the regular expression wriiten) it must print the output into the file. Currently I am able to traverse the harddrive perfectly, the regular expression and the search is perfect and when I print the output into the local console, I am able to derive perfect results. But when I use the PrintWriter to write the output into the flight, it writes NOTHING into the file. I have been scouring all over the Internet for an answer, but havent been able to find. Would highly appreciate if someone can tell me what I am doing wrong and provide some guidance on how to get it right.
    public class myClass{
        BufferedReader br;
        String pcv;
        Pattern scPattern = Pattern.compile("Some regular expression");
        Matcher match = null;
        Pattern newPattern = Pattern.compile("Some regular expression");
        Matcher newMatch = null;
        String mvCheckVal;
        Matcher mvMatch;
        PrintWriter pw;
        void recursiveMethod(File dir) throws Exception {
                pw = new PrintWriter(new FileWriter("outputFile.txt"));
                pw.println("Opening pw stream.....");
                File[] files = dir.listFiles();
                String[] fileList = dir.list();
                for (int i = 0;i < files.length; i++) {
                    if (files.isDirectory()) {
    continue;
    } else if (files[i].isFile()) {
    br = new BufferedReader(new FileReader(files[i]));
    pw.println("BR is opening....");
    String line;
    while((line = br.readLine()) != null) {
    match = scPattern.matcher(line);
    if (match.find()) {
    pcv = line.substring(match.start(), match.end());
    System.out.println("Match: " + pcv + " Context: " + match.replaceFirst(pcv)); //This is working perfectly
    pw.println("Match: " + pcv + " Context: " + match.replaceFirst(pcv)); //This does not print anything at all
    System.out.println("Files: " + files[i]);
    System.out.println("");
    pw.println(" Files: " + files[i]);
    pw.println("");
    System.out.println("Closing I/O....");
    br.close();
    pw.close();
    public static void main(String[]args) throws Exception {
    File dir = new File("C:/");
    myNewClass acf = new myNewClass();
    acf.myClass(dir);

    @ejp
    I am afraid that it is not working. Can you please tell me what I doing wrong.
    void myMethod(File dir) throws Exception {
                bw = new BufferedWriter(new FileWriter("outputFile.txt"));
                File[] files = dir.listFiles();
                String[] fileList = dir.list();
                for (int i = 0;i < files.length; i++) {
                    if (files.isDirectory()) {
    myMethod(files[i]);
    } else if (files[i].isFile()) {
    br = new BufferedReader(new FileReader(files[i]));
    String line;
    while((line = br.readLine()) != null) {
    match = scPattern.matcher(line);
    if (match.find()) {
    pcv = line.substring(match.start(), match.end());
    System.out.println("Match: " + pcv + " Context: " + match.replaceFirst(pcv));
    bw.write("Match: " + pcv + " Context: " + match.replaceFirst(pcv));
    br.close();
    bw.write("Files: " + files[i]);
    bw.write("");
    bw.close();
    public static void main(String[]args) throws Exception {
    File dir = new File("C:/");
    myClass acf = new myClass();
    acf.myMethod(dir);

  • [SOLVED]ZSH and regular expressions

    Hi
    I am getting into regular expressions and i have noticed that with my .zshrc file i have some problem. In bash this expression works:
    \^\[^#]
    but not also in zsh. I have also noted that regular expression works fine with other zshrc configurations found in archwiki (like grml) but i want to have my configuration. And i really can't find what command make a difference
    My .zshrc file is pulled from this site https://github.com/slashbeast/things/bl … s/DOTzshrc.
    # .zshrc
    # Author: Piotr Karbowski <[email protected]>
    # License: beerware.
    # Basic zsh config.
    umask 077
    ZDOTDIR=${ZDOTDIR:-${HOME}}
    ZSHDDIR="${HOME}/.config/zsh.d"
    HISTFILE="${ZDOTDIR}/.zsh_history"
    HISTSIZE='10000'
    SAVEHIST="${HISTSIZE}"
    export EDITOR="/usr/bin/vim"
    export TMP="$HOME/tmp"
    export TEMP="$TMP"
    export TMPDIR="$TMP"
    export TMPPREFIX="${TMPDIR}/zsh"
    if [ ! -d "${TMP}" ]; then mkdir "${TMP}"; fi
    if ! [[ "${PATH}" =~ "^${HOME}/bin" ]]; then
    export PATH="${HOME}/bin:${PATH}"
    fi
    # Not all servers have terminfo for rxvt-256color. :<
    if [ "${TERM}" = 'rxvt-256color' ] && ! [ -f '/usr/share/terminfo/r/rxvt-256color' ] && ! [ -f '/lib/terminfo/r/rxvt-256color' ] && ! [ -f "${HOME}/.terminfo/r/rxvt-256color" ]; then
    export TERM='rxvt-unicode'
    fi
    # Colors.
    red='\e[0;31m'
    RED='\e[1;31m'
    green='\e[0;32m'
    GREEN='\e[1;32m'
    yellow='\e[0;33m'
    YELLOW='\e[1;33m'
    blue='\e[0;34m'
    BLUE='\e[1;34m'
    purple='\e[0;35m'
    PURPLE='\e[1;35m'
    cyan='\e[0;36m'
    CYAN='\e[1;36m'
    NC='\e[0m'
    # Functions
    if [ -f '/etc/profile.d/prll.sh' ]; then
    . "/etc/profile.d/prll.sh"
    fi
    run_under_tmux() {
    # Run $1 under session or attach if such session already exist.
    # $2 is optional path, if no specified, will use $1 from $PATH.
    # If you need to pass extra variables, use $2 for it as in example below..
    # Example usage:
    # torrent() { run_under_tmux 'rtorrent' '/usr/local/rtorrent-git/bin/rtorrent'; }
    # mutt() { run_under_tmux 'mutt'; }
    # irc() { run_under_tmux 'irssi' "TERM='screen' command irssi"; }
    # There is a bug in linux's libevent...
    # export EVENT_NOEPOLL=1
    command -v tmux >/dev/null 2>&1 || return 1
    if [ -z "$1" ]; then return 1; fi
    local name="$1"
    if [ -n "$2" ]; then
    local file_path="$2"
    else
    local file_path="command ${name}"
    fi
    if tmux has-session -t "${name}" 2>/dev/null; then
    tmux attach -d -t "${name}"
    else
    tmux new-session -s "${name}" "${file_path}" \; set-option status \; set set-titles-string "${name} (tmux@${HOST})"
    fi
    t() { run_under_tmux rtorrent; }
    irc() { run_under_tmux irssi "TERM='screen' command irssi"; }
    over_ssh() {
    if [ -n "${SSH_CLIENT}" ]; then
    return 0
    else
    return 1
    fi
    reload () {
    exec "${SHELL}" "$@"
    confirm() {
    local answer
    echo -ne "zsh: sure you want to run '${YELLOW}$@${NC}' [yN]? "
    read -q answer
    echo
    if [[ "${answer}" =~ ^[Yy]$ ]]; then
    command "${=1}" "${=@:2}"
    else
    return 1
    fi
    confirm_wrapper() {
    if [ "$1" = '--root' ]; then
    local as_root='true'
    shift
    fi
    local runcommand="$1"; shift
    if [ "${as_root}" = 'true' ] && [ "${USER}" != 'root' ]; then
    runcommand="sudo ${runcommand}"
    fi
    confirm "${runcommand}" "$@"
    poweroff() { confirm_wrapper --root $0 "$@"; }
    reboot() { confirm_wrapper --root $0 "$@"; }
    hibernate() { confirm_wrapper --root $0 "$@"; }
    detox() {
    if [ "$#" -ge 1 ]; then
    confirm detox "$@"
    else
    command detox "$@"
    fi
    has() {
    local string="${1}"
    shift
    local element=''
    for element in "$@"; do
    if [ "${string}" = "${element}" ]; then
    return 0
    fi
    done
    return 1
    begin_with() {
    local string="${1}"
    shift
    local element=''
    for element in "$@"; do
    if [[ "${string}" =~ "^${element}" ]]; then
    return 0
    fi
    done
    return 1
    termtitle() {
    case "$TERM" in
    rxvt*|xterm|nxterm|gnome|screen|screen-*)
    local prompt_host="${(%):-%m}"
    local prompt_user="${(%):-%n}"
    local prompt_char="${(%):-%~}"
    case "$1" in
    precmd)
    printf '\e]0;%s@%s: %s\a' "${prompt_user}" "${prompt_host}" "${prompt_char}"
    preexec)
    printf '\e]0;%s [%s@%s: %s]\a' "$2" "${prompt_user}" "${prompt_host}" "${prompt_char}"
    esac
    esac
    git_check_if_worktree() {
    # This function intend to be only executed in chpwd().
    # Check if the current path is in git repo.
    # We would want stop this function, on some big git repos it can take some time to cd into.
    if [ -n "${skip_zsh_git}" ]; then
    git_pwd_is_worktree='false'
    return 1
    fi
    # The : separated list of paths where we will run check for git repo.
    # If not set, then we will do it only for /root and /home.
    if [ "${UID}" = '0' ]; then
    # running 'git' in repo changes owner of git's index files to root, skip prompt git magic if CWD=/home/*
    git_check_if_workdir_path="${git_check_if_workdir_path:-/root:/etc}"
    else
    git_check_if_workdir_path="${git_check_if_workdir_path:-/home}"
    git_check_if_workdir_path_exclude="${git_check_if_workdir_path_exclude:-${HOME}/_sshfs}"
    fi
    if begin_with "${PWD}" ${=git_check_if_workdir_path//:/ }; then
    if ! begin_with "${PWD}" ${=git_check_if_workdir_path_exclude//:/ }; then
    local git_pwd_is_worktree_match='true'
    else
    local git_pwd_is_worktree_match='false'
    fi
    fi
    if ! [ "${git_pwd_is_worktree_match}" = 'true' ]; then
    git_pwd_is_worktree='false'
    return 1
    fi
    # todo: Prevent checking for /.git or /home/.git, if PWD=/home or PWD=/ maybe...
    # damn annoying RBAC messages about Access denied there.
    if [ -d '.git' ] || [ "$(git rev-parse --is-inside-work-tree 2> /dev/null)" = 'true' ]; then
    git_pwd_is_worktree='true'
    git_worktree_is_bare="$(git config core.bare)"
    else
    unset git_branch git_worktree_is_bare
    git_pwd_is_worktree='false'
    fi
    git_branch() {
    git_branch="$(git symbolic-ref HEAD 2>/dev/null)"
    git_branch="${git_branch##*/}"
    git_branch="${git_branch:-no branch}"
    git_dirty() {
    if [ "${git_worktree_is_bare}" = 'false' ] && [ -n "$(git status --untracked-files='no' --porcelain)" ]; then
    git_dirty='%F{green}*'
    else
    unset git_dirty
    fi
    precmd() {
    # Set terminal title.
    termtitle precmd
    if [ "${git_pwd_is_worktree}" = 'true' ]; then
    git_branch
    git_dirty
    git_prompt=" %F{blue}[%F{253}${git_branch}${git_dirty}%F{blue}]"
    else
    unset git_prompt
    fi
    preexec() {
    # Set terminal title along with current executed command pass as second argument
    termtitle preexec "${(V)1}"
    chpwd() {
    git_check_if_worktree
    man() {
    if command -v vimmanpager >/dev/null 2>&1; then
    PAGER="vimmanpager" command man "$@"
    else
    command man "$@"
    fi
    # Are we running under grsecurity's RBAC?
    rbac_auth() {
    local auth_to_role='admin'
    if [ "${USER}" = 'root' ]; then
    if ! grep -qE '^RBAC:' "/proc/self/status" && command -v gradm > /dev/null 2>&1; then
    echo -e "\n${BLUE}*${NC} ${GREEN}RBAC${NC} Authorize to '${auth_to_role}' RBAC role."
    gradm -a "${auth_to_role}"
    fi
    fi
    #rbac_auth
    # Check if we started zsh in git worktree, useful with tmux when your new zsh may spawn in source dir.
    git_check_if_worktree
    if [ "${git_pwd_is_worktree}" = 'true' ]; then
    git_branch
    git_dirty
    git_prompt=" %F{blue}[%F{253}${git_branch}${git_dirty}%F{blue}]"
    else
    unset git_prompt
    fi
    # Le features!
    # extended globbing, awesome!
    setopt extendedGlob
    # zmv - a command for renaming files by means of shell patterns.
    autoload -U zmv
    # zargs, as an alternative to find -exec and xargs.
    autoload -U zargs
    # Turn on command substitution in the prompt (and parameter expansion and arithmetic expansion).
    setopt promptsubst
    # Control-x-e to open current line in $EDITOR, awesome when writting functions or editing multiline commands.
    autoload -U edit-command-line
    zle -N edit-command-line
    bindkey '^x^e' edit-command-line
    # Include user-specified configs.
    if [ ! -d "${ZSHDDIR}" ]; then
    mkdir -p "${ZSHDDIR}" && echo "# Put your user-specified config here." > "${ZSHDDIR}/example.zsh"
    fi
    for zshd in $(ls -A ${HOME}/.config/zsh.d/^*.(z)sh$); do
    . "${zshd}"
    done
    # Completion.
    autoload -Uz compinit
    compinit
    zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'
    zstyle ':completion:*' completer _expand _complete _ignored _approximate
    zstyle ':completion:*' menu select=2
    zstyle ':completion:*' select-prompt '%SScrolling active: current selection at %p%s'
    zstyle ':completion::complete:*' use-cache 1
    zstyle ':completion:*:descriptions' format '%U%F{cyan}%d%f%u'
    # If running as root and nice >0, renice to 0.
    if [ "$USER" = 'root' ] && [ "$(cut -d ' ' -f 19 /proc/$$/stat)" -gt 0 ]; then
    renice -n 0 -p "$$" && echo "# Adjusted nice level for current shell to 0."
    fi
    # Fancy prompt.
    if over_ssh && [ -z "${TMUX}" ]; then
    prompt_is_ssh='%F{blue}[%F{red}SSH%F{blue}] '
    elif over_ssh; then
    prompt_is_ssh='%F{blue}[%F{253}SSH%F{blue}] '
    else
    unset prompt_is_ssh
    fi
    case $USER in
    root)
    PROMPT='%B%F{cyan}%m%k %(?..%F{blue}[%F{253}%?%F{blue}] )${prompt_is_ssh}%B%F{blue}%1~${git_prompt}%F{blue} %# %b%f%k'
    PROMPT='%B%F{blue}%n@%m%k %(?..%F{blue}[%F{253}%?%F{blue}] )${prompt_is_ssh}%B%F{cyan}%1~${git_prompt}%F{cyan} %# %b%f%k'
    esac
    # Ignore lines prefixed with '#'.
    setopt interactivecomments
    # Ignore duplicate in history.
    setopt hist_ignore_dups
    # Prevent record in history entry if preceding them with at least one space
    setopt hist_ignore_space
    # Nobody need flow control anymore. Troublesome feature.
    #stty -ixon
    setopt noflowcontrol
    # Fix for tmux on linux.
    case "$(uname -o)" in
    'GNU/Linux')
    export EVENT_NOEPOLL=1
    esac
    # Aliases
    alias cp='cp -iv'
    alias rcp='rsync -v --progress'
    alias rmv='rsync -v --progress --remove-source-files'
    alias mv='mv -iv'
    alias rm='rm -iv'
    alias rmdir='rmdir -v'
    alias ln='ln -v'
    alias chmod="chmod -c"
    alias chown="chown -c"
    if command -v colordiff > /dev/null 2>&1; then
    alias diff="colordiff -Nuar"
    else
    alias diff="diff -Nuar"
    fi
    alias grep='grep --colour=auto'
    alias egrep='egrep --colour=auto'
    alias ls='ls --color=auto --human-readable --group-directories-first --classify'
    # Keys.
    case $TERM in
    rxvt*|xterm*)
    bindkey "^[[7~" beginning-of-line #Home key
    bindkey "^[[8~" end-of-line #End key
    bindkey "^[[3~" delete-char #Del key
    bindkey "^[[A" history-beginning-search-backward #Up Arrow
    bindkey "^[[B" history-beginning-search-forward #Down Arrow
    bindkey "^[Oc" forward-word # control + right arrow
    bindkey "^[Od" backward-word # control + left arrow
    bindkey "^H" backward-kill-word # control + backspace
    bindkey "^[[3^" kill-word # control + delete
    linux)
    bindkey "^[[1~" beginning-of-line #Home key
    bindkey "^[[4~" end-of-line #End key
    bindkey "^[[3~" delete-char #Del key
    bindkey "^[[A" history-beginning-search-backward
    bindkey "^[[B" history-beginning-search-forward
    screen|screen-*)
    bindkey "^[[1~" beginning-of-line #Home key
    bindkey "^[[4~" end-of-line #End key
    bindkey "^[[3~" delete-char #Del key
    bindkey "^[[A" history-beginning-search-backward #Up Arrow
    bindkey "^[[B" history-beginning-search-forward #Down Arrow
    bindkey "^[Oc" forward-word # control + right arrow
    bindkey "^[Od" backward-word # control + left arrow
    bindkey "^H" backward-kill-word # control + backspace
    bindkey "^[[3^" kill-word # control + delete
    esac
    bindkey "^R" history-incremental-pattern-search-backward
    bindkey "^S" history-incremental-pattern-search-forward
    if [ -f ~/.alert ]; then cat ~/.alert; fi
    Thanks for all the help.
    Last edited by Shark (2013-05-11 22:32:24)

    Raynman wrote:
    "This expression doesn't work", "It doesn't work" ...
    Could you try being a bit more specific?
    Firstly, i am sorry i didn't post the output. I should have know better.
    Secondly, chill out.
    I have used above regex with grep command. Output from terminal is:
    zsh: bad pattern: ^[^#]
    In bash it works perfectly.
    If i issue "setopt re_match_pcre" i have the same ouput as above.
    EDIT: If i issue "unsetopt no_match" it actually works but i have to change the regex from "\^\[^#]" to "\^[^#]" otherwise i get the same output as above. In bash both options work.
    Last edited by Shark (2013-05-11 22:07:21)

  • Regular Expressions in num-exp

    Hello All,
    I had a problem on my SRST gateway with num-exp insterting a repeating pattern into my 7-digit dialing when in fallback mode.
    For a brief example, the 7digit internal dialing is 21621.. or 21622..
    The num-exp statement of 'num-exp 2... 2162...' was not allowing me to 7-digit dial directly from one IP phone to another while in fallback mode.
    When I dialed 2162154 the 2162 would hit the num-exp and be expended to 2162162.
    I have a work around that uses a voice translation-rule, applied to the call-manager-fallback config that will translate a 7-digit dialed string to the 4 digit dialed string which then hits the 4-digit to 7-digit num-exp and it is working fine.
    However, I was wondering if there is a way to  use regular expressions in num-exp so that perhaps I can skip the intermediate step of using the translation-rule. Based off my existing translation-rules that are working properly, I figured something like this might work for num-exp:
    'num-exp /^2\([12]..$\)/ /2162\1/'
    But when I try to issue a num-exp with a regular expression I get the following message.
    Incorrect format for Number macro pattern
            regular expression must be of the form  ^((\+)?([0-9#*A-F.]|(\\\*))+(\$)?)$
    I have tried a number of different combinations with no success.  I always get the same message.  The regular expression that I tried first was:
    'num-exp ^2... 2162...'
    This is when I first saw the "Incorrect format..." message and figured that is must be possible.  Is this just a generic warning similar to when you try to use complex regular expressions with the 'translation-rule' command vs. the 'voice translation-rule' command and in reality you cannot use regular expressions in the num-exp command?
    Thank you,
    Leo

    Hi Chris,
    Thank you for taking the time to answer my question.  It looks like the answer is no, num-exp does not support regular expressions.
    I don't insist on using num-exp for this I was just hoping to kill two birds with one stone and possibly skip the intermediate step of translating the 7-digits dial to 4-digits using a translation-rule just to expand from 4-digit to 7 again.  This is only an issue while in SRST if a user tries to dial using 7-digits.  We have a 7-digit internal dialing scheme and normally my num-exp is just to expand the 4 digits sent from the telco to our 7-digit internal dialing.  The problem is that both our prefix and part of our DID range start with 21 so while in SRST if a user tried to dial a 7-digit DN, say 2162154, after they dialed the 4th digit (2162) that pattern would hit the num-exp and get expanded to 2162162.  I was hoping to create a num-exp using a regular expression that would only expand a four digit string that begins with a 2 to seven digits and not any string that begins with a 2.  This would 1) expand the four digits sent from the telco and 2) not match a seven digit string that begins with a 2 such as 2162154 which may be dialed by a user.
    Again, this is only an issue while in SRST and I have a pretty good work around so I'm fine with not being able to use a regular expression as part of my num-exp config.  I just thought it would be a cool application of a regular expression if it was possible.
    Thanks again for answering my question.
    Leo

  • Regular Expressions in CS5.5 - something is wrong

    Hello Everybody,
    Please correct me, but I think, I found a serious problem with regular Expressions in Indesign CS5.5 (and possibly in other apps from CS5.5).
    Let's start with simple example:
    var range = "a-a,a,a-a,a";
    var regEx = /(a+-a+|a+)(,(a+-a+|a+))*/;
    alert( "Match:" +regEx.test(range)+"\nLeftContext: "+RegExp.leftContext+"\nRightContext: "+RegExp.rightContext );
    What I expected was true match and the left  and the right context should be empty. In Indesign CS3 that is correct BUT NOT in CS5.5.
    In CS 5.5 it seems that the only first "a-a" is matched and the rest is return as the rightContext - looks like big change (if not parsing error in RegExp engine).
    Please correct me if I am wrong.
    The second example - how to freeze ID CS5.5:
    var range = "a-a,a,a-a,a";
    var regEx = /(a+-a+|a+)(,(a+-a+|a+)){8,}/;
    alert( "Match:" +regEx.test(range)+"\nLeftContext: "+RegExp.leftContext+"\nRightContext: "+RegExp.rightContext );
    As you can see it differs only with the {8,} part instead of *
    Run it in CS5.5 and you will see that the ID hangs (in CS3 of course it runs flawlessly}.
    The third example - how to freeze ID 5.5 in one line (I posted it earlier in Photoshop forum because similiar problem was called earlier):
    alert((/(n|s)? /gmi).test('s') );
    As you can guess - it freezes the CS5.5 (CS3 passes the test).
    Please correct me if I am doing something wrong or it's the problem of Adobe.
    Best regards,
    Daniel Brylak

    Hi Daniel,
    Thanks for sharing. Really annoying indeed.
    Just to complete your diagnosis, what you describe about CS.5 is the same in CS5, while CS4 behaves as CS3.
    var range = "aaaaa";
    var regEx = /(a+-a+|a+)(,(a+-a+|a+))*/;
    alert([
        "Match:" +regEx.test(range),
        "LeftContext: "+RegExp.leftContext.toSource(),        // => CS3/4: EMPTY -- CS5+: EMPTY
        "RightContext: "+RegExp.rightContext.toSource()        // => CS3/4: EMPTY -- CS5+: ",a,a-a,a"
        ].join('\r'));
    So there is a serious implementation problem of the RegExp object from ExtendScript CS5.
    I don't think it's related to the greedy modes. By default, JS RegExp quantifiers are greedy, and /a*/ still entirely captures "aaaaaa" in CS5+.
    By the way, you can make any quantifier non-greedy by adding ? after the quantifier, e.g.: /a*?/, /a+?/, etc.
    I guess that Adobe ExtendScript has a generic issue in updating the RegExp.lastIndex property in certain contexts—see http://forums.adobe.com/message/3719879#3719879 —which could explain several bugs such as the Negative Class bug —see http://forums.adobe.com/message/3510078#3510078 — or the problems you are mentioning today.
    @+
    Marc

  • Problems with java regular expressions

    Hi everybody,
    Could someone please help me sort out an issue with Java regular expressions? I have been using regular expressions in Python for years and I cannot figure out how to do what I am trying to do in Java.
    For example, I have this code in java:
    import java.util.regex.*;
    String text = "abc";
              Pattern p = Pattern.compile("(a)b(c)");
              Matcher m = p.matcher(text);
    if (m.matches())
                   int count = m.groupCount();
                   System.out.println("Groups found " + String.valueOf(count) );
                   for (int i = 0; i < count; i++)
                        System.out.println("group " + String.valueOf(i) + " " + m.group(i));
    My expectation is that group 0 would capture "abc", group 1 - "a" and group 2 - "c". Yet, I I get this:
    Groups found 2
    group 0 abc
    group 1 a
    I have tried other patterns and input text but the issue remains the same: no matter what, I cannot capture any paranthesized expression found in the pattern except for the first one. I tried the same example with Jakarta Regexp 1.5 and that works without any problems, I get what I expect.
    I am using Java 1.5.0 on Mac OS X 10.4.
    Thank to all who can help.

    paulcw wrote:
    If the group count is X, then there are X plus one groups to go through: 0 for the whole match, then 1 through X for the individual groups.It does seem confusing that the designers chose to exclude the zero-group from group count, but the documentation is clear.
    Matcher.groupCount():
    Group zero denotes the entire pattern by convention. It is not included in this count.

  • Using regular expressions in content dictionaries

    I need to create a content dictionary containing regular expressions. I also need to use the "\" to escape some characters that would otherwise be regex meta-characters. When using a regex in a message filter, the "\" must be doubled because of parsing issues. This is clearly documented in the manual. What isn't documented is whether this must be done when the regex is within a content dictionary.
    Here's an example:
    if (mail-from == "@bad-domain\\.com$") { drop(); }
    I want to change this filter to:
    if (mail-from-dictionary-match("bad-domains")) { drop(); }
    So what do I put in the content dictionary, "@bad-domain\.com$" or "@bad-domain\\.com$"?
    Thanks,

    You should use this:
    "@bad-domain\.com$"
    The above tells the system to deference the "." (any character) to mean a literal period.
    If you used this,
    @bad-domain\\.com$
    What the system would match is "@bad-domain\.com", because the first backslash would dereference the second backslash, to be taken literally. So, the double backslashes is the wrong format.
    The only reason you see it in the final results when you've committed changes is that the system adds the backslash for you so that there's no error when it gets compiled.
    Also, you could have left the single backslash out completely too and it would probably work.
    "@bad-domain.com$"
    If you sed that as your pattern in the dictionary, it would match against these:
    @bad-domain.com
    @bad-domainncom
    @bad-domain1com
    @bad-domain&com
    basically, the "." means any character. But to be precise, you should only add one backslash in front of special characters. Here is a list of special characters:
    | ( ) [ { ^ $ * + ? .
    For a detailed explanation about special characters and how to use them, please see the Advanced User Guide.
    [https://supportportal.ironport.com/irppcnctr/srvcd?u=http://secure-support.soma.ironport.com/subproducts/x-c_series&sid=900001]

  • Does Safari support the lazy operator in a JavaScript regular expression?

    I've already filed a bug for this. Anyway I'd like to know if you already knew it.
    If you go to http://noteslog.com/personal/projects/regexp/test.html you'll see an input box and a "Go!" button. Put a JavaScript regular expression in the box and click the button. Shortly you'll see a red line showing how many characters have been matched.
    If you try
    \[\w\W\]
    you get a correct result (all matched)
    but if you try
    <\?\[\w\W\]*?\?>
    you get a wrong result (nothing matched) and the issue is due to the fact that the ? after the * is not treated as a laziness operator.
    Test in IE, FF, and Opera too, and you'll see that they work as expected.
    Message was edited by: Andrea Ercolino

    If you try it from http://regexpal.com/ you'll see that it works as it should in IE and FF but not in Safari.
    Message was edited by: Andrea Ercolino

  • Regular Expressions on an online database

    Hi everyone, I'm kinda new so if what I'm about to ask seems crazy bear with me.
    What kind of issues would be involved with using a regular expression to search an online database?
    The Site says that Java 1.4 now supports a great deal of regex functions but I'm wondering would it be possible to type a regex into some control and for t to evaluate this against what's in the Database?
    Am I making sense?
    Thanks everyone,
    Robin Spiteri.

    Normally you access a database via JDBC & SQL. So the question is whether SQL supports regular expressions; this has nothing to do with java (any version). As far as I know regexps are not part of standard SQL although this might not be true for all SQL databases --> I think you cannot use regexps directly to query a database.
    If the database you're using supports regexps, and you are really sure that this will be "THE" database, and the system won't change, you can of course included regexps in the SQL, but that'll make it difficult to move to another database
    What you definitely can do is loop through the resultset and kick out the records you don't want, e.g.
    while(rs.next()) {
      if(!matchMyRegExp(rs.getString(1))) {
        // loop if reg exp is not matched
        continue;
      // do something
    }This should work on any database, but at the cost of transferring more data than needed from the db to the application.

  • Regular expression in OWB

    Hi
    Can the following be done in OWB using operators
    SELECT DISTINCT column1
    FROM ( SELECT DISTINCT REGEXP_SUBSTR (description,
    '[^[:blank:][:punct:] ]+',
    1,
    LEVEL)
    column1,
    LEVEL
    FROM (SELECT FREE_TEXT DESCRIPTION FROM TEST_TABLE)
    CONNECT BY LEVEL <=
    LENGTH (REGEXP_REPLACE (description, '[[:alnum:]]'))
    + 1
    ORDER BY LEVEL)
    WHERE column1 IS NOT NULL
    TEST_TABLE is a table with following data
    FREE_TEXT
    THE MAN IS WIELDING A SPADE
    A%WOMAN,WAS SEEN.
    1 THE'GIRL IS LAUGH$ING
    Output as from SQL is
    Column1
    GIRL
    1
    SPADE
    WIELDING
    IS
    THE
    MAN
    WAS
    WOMAN
    SEEN
    ING
    LAUGH
    A
    Cheers
    Birdy

    Hi David
    I was trying to improve the performance of the above query after tips from some forums.
    The new query is
    SELECT REGEXP_SUBSTR ( free_text, '[^[:blank:][:punct:] ]+', 1, lvl)
    FROM Test_table,
    (SELECT LEVEL lvl
    FROM (SELECT MAX (LENGTH (REGEXP_REPLACE ( free_text, '[[:alnum:]]'))) mx
    FROM Test_table)
    CONNECT BY LEVEL <= mx + 1)
    WHERE lvl - 1 <= LENGTH (REGEXP_REPLACE ( free_text, '[[:alnum:]]'))
    ORDER BY lvl;
    The only issue I am facing is to get the max of length of regular expression.
    I am not sure whether this will be possible in a mapping as we cannot have aggregations in a filter condition...
    I even tried to first get the value MAX (LENGTH (REGEXP_REPLACE ( free_text, '[[:alnum:]]'))) in an aggregator and then use is further but the data flow will change as I will have to go through the aggregator.
    Not sure how to go about this now. I guess I will have to embed it in a function.
    The old query mapping works but is way too slow.
    Birdy

Maybe you are looking for

  • Would it be possible to install 1TB HD in a Mac Mini ?

    That´s my question: Can I install 1TB HD in a Mac Mini? I haven´t read anything in Tech Specs but I would like to do it if it were possible. Regards. Guillermo

  • Windows 7 wont install in boot camp

    Hi, I just completely wiped my MacBook and reinstalled Leopard and it's working fine and I wanted to use Boot Camp with Windows 7 Professional and i had it all going well until I was installing Windows and it said that it can only install on a NTSF f

  • Pointer disappears on a black background

    Is there a way to change the color of, or outline, the pointer when working in an app's panel that, unfortunately, has a black background? Changing the size doesn't help. Thanks!

  • Error - No cost price was found,  Code -10

    Hi, I am trying to create an A/R Invoice from the SBO UI. I am setting the values for DocNum, CardCode, DocDate, DocDueDate and ItemCode, Quantity, Price, TaxCode. When i click on Add it shows an error message - No cost price was found 'itemcode'. Wh

  • CS6 breaks ActionScript 2.0 projects. No var property for TextInput or Label.

    I've been programming for years, but I'm brand new to Flash. For various reasons, I need to learn ActionScript 2.0 instead of 3.0. All I could get from Adobe's website is the trial for CS6. When I look at tutorials for AS2, controls such TextInput an