Bug in ExtendScript regular expressions

I don't know if this is a problem with javascript in general or photoshop's hosting of it.  The bug reporting area looks dicey so I'm posting it here too.
This expression: "a_bs".match(/^\s*(A)(?:_B|_BS)?\s*$/i)
Evaluates to: a_bs,
That is it fails to report the grouped (a) up there.  Obviously I'm using it in a more complex manner (a bunch of |s inside the first group).
The following works as I'd expect.
This expression: "a_bs".match(/^\s*((A)(?:_B|_BS)?)\s*$/i)
Evaluates to: a_bs,a_bs,a
It DOES pick up the a in its group.  Both ruby and python agree with me.  If anyone from Adobe is listening, please fix it.
Thanks,
Adrian

Each rev fixes some RegExp bugs and introduces new ones. It's tedious but do report your bugs at adobe.com. The have fixed some of mine.
Also, sometimes ESTK and PS have different bugs.

Similar Messages

  • [CC] Search&Replace: Bug only with Regular Expressions

    Can you confirm the following behaviour/bug?
    Steps to reproduce:
    1 Create a new document in DW CC
    2 Enter that text in the source code view:
    <p>&euro;</p>
    3 Open Search&Replace
    Field Search in: Current document
    Field Search: Text
    Field Search (3rd Field): €
    Start Search
    Result: As expected the "€" is found.
    4 [x] Regular Expressions
    Start Search
    Result: "€" isn't found
    Can you reproduce that?
    Do you regard that as a bug like me?
    If not, why please?
    Do you think it is technically impossible for the developers to solve the task?
    Do you think the developers forgot to gray out "text" in the choice box and allow regular expressions only in source code?
    Thanks.

    Nice that you like the nick
    Sure, I know that I can file a feature wish.
    But my main interest in this forum is to know, what other users think about certain features, why they think so, which they miss, which they regard as a bug, ...
    When I remember it right, you told me some time ago, that you don't use RegEx.
    Than I understand, that everything around that feature is not important for you.
    What I like to understand is, why you think the behaviour is logically.
    For me it is the opposite.
    You get a result with "Scope: Text", "[ ]RegEx".
    And you get no result with "Scope: Text", "[x]RegEx".
    Incredible strange.
    I would appreciate, if you could explain more detailed your view.

  • Bugs in the REGULAR EXPRESSIONS ORACLE10g

    Hi....
    In the next URL http://otn.oracle.com/oramag/webcolumns/2003/techarticles/rischert_regexp_pt1.html
    Have a next title Writing More Complex Patterns , and the code is :
    SELECT REGEXP_INSTR('Joe Smith, 10045 Berry Lane, San Joseph, CA 91234-1234',
    ' [[:digit:]]{5}(-[[:digit:]]{4})?$')
    AS starts_at
    FROM dual
    I see this code in the Table 7 in the URL
    http://otn.oracle.com/oramag/webcolumns/2003/techarticles/rischert_regexp_pt2.html#t7
    But , the explanation of the code have a error in the pocket number 11 ..
    Say :
    [:digit] POSIX [:digit] class
    [ Start of character list[/b]
    ] End of character list
    {4} Repeat exactly four ocurrences of the character list
    it would be to say :
    [:digit] POSIX [:digit] class
    ] End of character list
    {4} Repeat exactly four ocurrences of the character list
    it has more than enough the line 11
    Regards
    Hector Gabriel Ulloa Ligarius
    PD : Sorry my english

    Thanks for pointing this out...the error has been corrected.

  • Bug in ExtendScript's regular expression engine

    I'm using ExtendScript 3.92.115, and I'm noticing that a certain regular expressions don't work properly.  I've tried the same expressions on popular browsers, and they work fine.  Here's an example:
    alert('ab'.match(/(.)(?:.*?)$/));
    The alert should display the array: ["ab", "a"], because there is a match ("ab"), and one capturing group ("(.)" captures "a").  Instead it displays ["ab", undefined], which makes no sense.  It works fine if both groups are capturing: "(.)(.*?)$", if you remove the non-greedy modifier: "(.)(?:.*)$", or even if you don't group the second part: "(.).*?$".
    Any thoughts?  I can modify my regular expressions to work around these problems, but it'd be good to fix the engine if it's really broken, as I suspect.
    Thanks!

    Each rev fixes some RegExp bugs and introduces new ones. It's tedious but do report your bugs at adobe.com. The have fixed some of mine.
    Also, sometimes ESTK and PS have different bugs.

  • BUG?? Syntax Highlighting Regular Expressions

    I'm working on a rather long regular expression in
    dreamweaver code view. It has about 200+ characters in it.
    I wrote it in another application and copied it over for use
    in js, and it wouldn't highlight correctly (sort of like when you
    leave off quote on a string). Naturally I thought I screwed up my
    regexp or forgot to escape a character or something so I went
    through it re-writing it and checking everything but it was
    correct. I saved the page and ran it in the browser and sure enough
    it worked.
    So I started typing the regexp from scratch this time in
    dreamweaver to see when it stopped highlighting correctly. It
    stopped at exactly 100 characters including opening and closing
    forward slashes. I tried writing another exp this time filled with
    just one letter. Again 100 characters exactly - not one more.
    Example:
    var reg1 =
    /ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss ssssssssss/
    var reg2 =
    /ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss sssssssssss/
    reg1 will highlight correctly, while reg2 won't.
    Is this a bug or am I missing something? The highlight rule
    (in Configuration\CodeColoring\CodeColoring.xml) is
    (\s*/\e*\\/
    -or-
    =\s*/ \e*\\ /
    There seems to be no limitation to length there.
    While this is not a huge deal, I might as was well be coding
    in notepad (or my other script editors which highlight this
    correctly) because the highlighting is worthless from this point
    on.
    I could make these strings instead of literals but I have a
    lot of these long expressions and would rather not go through them
    and escape all of my back slashes (there are tons) as well as
    quotes - and make them more un-maintainable as they already are.
    Anyone have this problem? Or a solution to it?

    random_acts wrote:
    > I'm working on a rather long regular expression in
    dreamweaver code view. It
    > has about 200+ characters in it.
    I have never written a regex as long as that, but was
    fascinated by your
    question, so attempted to replicate your problem.
    I gave up at 614 characters, but the syntax coloring didn't.
    I suggest
    that you submit a bug report with the details of your actual
    code:
    http://www.adobe.com/cfusion/mmform/index.cfm?name=wishform
    David Powers
    Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
    Author, "Foundation PHP 5 for Flash" (friends of ED)
    http://foundationphp.com/

  • 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

  • Get all groups from a regular expression match

    Please help me understand how to use Java regular expressions:
    I have an expression similar to this:
    {noformat}"([^X]+)(X[^X]*)+"{noformat}This should match stuff like "asaasaXdfdfdfXXsdsfd".
    How does one access all the matches for the second group (the second groups has a Kleene operator
    added so it is not really just one group --- but match.groupCount() is always 2)
    Here is roughly the code:
    {noformat}java.util.regex.Pattern pattern = {noformat}{noformat}java.util.regex.Pattern.compile({noformat}{noformat}"([^X]+)(X[^X]*)+",{noformat}{noformat}java.util.regex.Pattern.MULTILINE{noformat}{noformat});{noformat}{noformat}java.util.regex.Matcher matcher = pattern.matcher(text);{noformat}{noformat}matcher.find();{noformat}{noformat}int groupcount = matcher.groupCount();{noformat}
    Also, without matcher.find() I get an illegalStateException .. which I also get if I use matcher.matches() instead
    of matcher.find().
    I am obviously missing something here. There is always at least one "X" in the string so shouldn't that pattern always
    match the whole string? Since there are often multiple X, shouldnt I get a group for each occurrence of X, followed
    by 0 or more other characters?
    {noformat}But when I try to match everything by using "^([^X]+)(X[^X]*)+$" I get an "IllegalStateException: No match available" again.{noformat}
    What is the correct way to do this?
    Edited by: johann_p on May 16, 2008 10:39 AM

    I am sorry I messed this up. Here is a SSCCE:
    import java.util.regex.Pattern;
    import java.util.regex.Matcher;
    class RegExp1 {
        public static void main(String[] args) {
          String testString = "first|aaaa | bbbb\n|cccc|ddddd";
          Pattern pattern = Pattern.compile("^([^|]+)(\\|[^|]*)+$");
          Matcher matcher = pattern.matcher(testString);
          matcher.find();
          int groupcount = matcher.groupCount();
          System.out.println("Found "+groupcount+" groups");
          System.out.println("Matcher: "+matcher);
          for (int i = 1; i <= groupcount; i++) {
            System.out.println("Match "+i+": "+testString.substring(matcher.start(i),matcher.end(i)));
    }I figured out a small bug in my first code that explains some of the exception oddities, but my principal question remains:
    how do I access all the matches that correspond to the second capturing group?
    In the example I would get "first" for Match 1 and "|ddddd" for Match 2, but how do I access all the matches??
    Thank you for your help!

  • [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 and back references

    Just wanted to know if anyone else noticed that.
    In the javadoc of java.util.regex.Pattern in the "Back references" section it says that you need to use \n to match capturing group but it does not work. To match a capturing group one need to use a "$" sign which is not standard for this type of operation.
    For example, the following code should work according to the API and most other regular expression engines:
    Pattern.compile("([A-Z])").matcher("ThisIsATestString").replaceAll(" \1");
    But to make this work you need to use:
    Pattern.compile("([A-Z])").matcher("ThisIsATestString").replaceAll(" $1");
    So, is this just a doc bug or am I missing something?
    Someone have any idea why Sun choose to use the "$" sign instead of the regular "\" sign??
    TIA,
    Shaul

    The doc you're referring to is talking about using back-refereneces within the regex, not in the replacement string. For instance, if you wanted to find all instances of things like "foo-foo" or "bar-bar", you would use a Pattern like   Pattern p = Pattern.compile("([a-z]+)-\\1");For the most part, they've made the syntax the same a Perl's regexes, and that's why they use $n instead of \n in the replacement string. The replacement string is described in the Matcher javadoc.

  • 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);

  • Regular expressions help

    I'm using a RegExp class (http://www.jurjans.lv/flash/RegExp.html) to do some regular expression in AS2. But I'm not very good at it.
    var str:String="What if there are other variables, such as possible <a class='gloss' href='asfunction:_root.handle, confounding variables'><b>confounding variables</b></a> which could explain at least some of the relationship between the two variables? Here <a href='' target='_blank'>is another link</a>.\n<a class='gloss' href='asfunction:_root.handle, confounding variables'>confounded variables</a>"
    var reg1:RegExp = new RegExp("<a.*gloss.*href=[\'\"]?([^\\\'\">]+)>+(.*</a>)", "ig");
    var obj:Object = reg1.exec(str);
    while (obj != null) {
              for(var a in obj){
                        if(!isNaN(a)){
                        trace(a+": "+obj[a]);
              trace(newline);
              obj = reg1.exec(str);
    And this traces:
    2: <b>confounding variables</b></a>
    1: asfunction:_root.handle, confounding variables'
    0: <a class='gloss' href='asfunction:_root.handle, confounding variables'><b>confounding variables</b></a>
    2: confounded variables</a>
    1: asfunction:_root.handle, confounding variables'
    0: <a class='gloss' href='asfunction:_root.handle, confounding variables'>confounded variables</a>
    I'm trying to get the href and the "friendly link" part of the anchor tag (but only for anchors that have a class of gloss).
    As you can see I'm almost there, but I'm getting the extra </a> and the extra ' on the two examples. I tried putting the ) before the </a> but that just broke it. (Of course that could be because this class doesn't work properly, but I'm guessing that isn't the case.)
    Anybody really good with regular expressions who can help me out?

    Looks like there is a "greedy" bug with the () in that AS2 implementation.
    I also have a problem the expression matching not the next occurance of the closing </a> but the final one.
    Anybody have any ideas of other ways to do this?

  • 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 Expression Fails String replaceAll

    I am trying to use regular expressions to replace double backslashes in a string with a single backslash character. I am using version 1.4.2 SDK. Upon invoking the replaceAll method I get a stack trace. Does this look like a bug to anyone?
    String s = "text\\\\";  //this results in a string value of 'text\\'
    String regex = "\\\\{2}";  //this will match 2 backslash characters
    String backslash = "\\";
    s.replaceAll(regex,backslash); java.lang.StringIndexOutOfBoundsException: String index out of range: 1
         at java.lang.String.charAt(String.java:444)
         at java.util.regex.Matcher.appendReplacement(Matcher.java:551)
         at java.util.regex.Matcher.replaceAll(Matcher.java:661)
         at java.lang.String.replaceAll(String.java:1663)
         at com.msdw.fid.fitradelinx.am.client.CommandReader.read(CommandReader.java:55)
         at com.msdw.fid.fitradelinx.am.client.CommandReader.main(CommandReader.java:81)
    Exception in thread "main"

    Skinning the cat -
    public class Fred12
        public static void main(String[] args)
                String s = "text\\\\";  //this results in a string value of 'text\\'
                String regex = "[\\\\]{2}";  //this will match 2 backslash characters
                String backslash = "\\\\";
                System.out.println(s.replaceAll(regex,backslash));
                String s = "text\\\\";  //this results in a string value of 'text\\'
                String regex = "(\\\\){2}";  //this will match 2 backslash characters
                String backslash = "\\\\";
                System.out.println(s.replaceAll(regex,backslash));
                String s = "text\\\\";  //this results in a string value of 'text\\'
                String regex = "(?:\\\\){2}";  //this will match 2 backslash characters
                String backslash = "\\\\";
                System.out.println(s.replaceAll(regex,backslash));
                String s = "text\\\\";  //this results in a string value of 'text\\'
                String regex = "(?:\\\\)+";  //this will match 2 or more backslash characters
                String backslash = "\\\\";
                System.out.println(s.replaceAll(regex,backslash));
                String s = "text\\\\";  //this results in a string value of 'text\\'
                String regex = "\\\\\\\\";  //this will match 2 backslash characters
                String backslash = "\\\\";
                System.out.println(s.replaceAll(regex,backslash));
    }

  • Regular expressions: find files with exactly 'n' digits in a row

    Hi there,
    I want to filter files that contain only a fixed number of digits, but not more (at least not in after the digits).
    For example, I have
    01.mp3
    02.mp3
    test10.txt
    test000110101010.txt
    04.flac
    and for n=2 I want to get all files except 'test000110101010.txt'.
    The following is not working, and I'm a total newb regarding regular expressions
    ls -l | grep '^-' | awk '{print $9}' | grep '([0-9]\{2\})[^0-9]\{2\}'
    Thanks for help.
    Regards,
    drm

    Thanks!
    I wrote a python script to scan e.g. a music folder for missing files and needed to extract the file numbers from the files to get the "highest" number.
    You can get it from here: http://pastebin.com/Sg9yDHiw (Python3, expires in 1 month)
    Regards,
    drm
    Edit: found a bug
    Last edited by drm00 (2011-02-04 13:57:43)

  • [DW CC] Regular Expression and Back Reference in "Replace with": Escape

    I have a problem with escaping a character in "Replace with".
    Let's assume the following situation:
    Content:
    foobar
    Search for:
    (foo)(bar)
    Replace by:
    $1zot$2
    Result:
    foozotbar
    Everything is fine.
    But I want to insert the number "2" in between foo and bar.
    When I use
    Replace by: $12$2
    The result is:
    $12$2
    It seems that the regex engine interpretes the "$12" as a whole. And because there's no back reference with the count "12" DW cannot work correctly.
    The question:
    How can I "escape" the "2"?
    Thanks.

    Dreamweaver uses JavaScript for its Find and Replace with regex.
    I've just checked the Regular Expressions Cookbook by Jan Goyvaerts and Steven Levithan (O'Reilly). It deals with exactly this sort of situation where capturing groups can be ambiguous. This is what it says:
    "Java and JavaScript try to be clever with $10 [and above]. If a capturing group with the two-digit number exists in your regular expresssion, both digits are used for the capturing group. If fewer capturing groups exist, only the first digit is used to reference the group, leaving the second as a literal. Thus $23 is the 23rd capturing group, if it exists. Otherwise, it is the second capturing group followed by a literal 3."
    In other words, there is no way to escape the 2 in the Replace field. It would appear there's a bug in Dreamweaver's use of capturing groups.

Maybe you are looking for

  • Film download error on ipod touch

    I have tried to download a film to my son's ipod touch, but it won't download.  It says "download error.  tap to retry" - when I tap it does the same. How can I get it to download?  Or obtain refund from itunes? TIA Nadine

  • Material Creation date by plant

    Hello all, In several of our report I need to enter the creation date of the material. My problem is that the creation date of material is a global information and sits in MARA. The users run the report by plant and therefore they are interested to k

  • Unable to map PDF via Infornatica Conversion Agent

    All, i'm trying to build a scenario in which pdf is being parsed to xml via Informatica Itemfiled convertor agent. I've created such mapping  based on the agent tutorial (used the sample pdf file) -  it was just fine. When i tried to use my pdf (whic

  • HT3131 my monitor will not show desktop in closed clamshell?

    When I have my Macbook Pro Open, my monitor is on.  When I close my macbook pro (clamshell closed) my external monitor goes blank.  I bought my macbook pro in 2011.  I run Mountain Lion.  This just started occuring today.  Prior to today, it worked f

  • How do I define the five levels of text in a text placeholder ?

    Keybote User manual says, at page 234 ("Defining Text Placeholders") that I can create a Text Box in a master, define it as a "Text Placeholder" and : 7. Select the placeholder text and format it as desired. In a text box, you can define attributes f