RW_NO_STL & extended regular expressions

Hi
I wonder if anyone can help me. We are working on a solaris 2.6 and using the SUN Workshop C++ (v5.1) compiler. I'm trying to compile one of the roguewave examples
?/SUNWspro/WS6/examples/Tools.h++/rw/manual/extrgexp.cpp
this is an extended regular expression example. My compile statement is
CC -I/opt/SUNWspro/WS6/include/CC/Cstd -I/opt/SUNWspro/WS6/include/CC/Cstd -o -c extrgexp.o extrgexp.cpp -library=rwtools7,iostream
I get the following error
"/opt/SUNWspro/WS6/include/CC/rw7/rw/re.h", line 184: Warning: #error You must have both Standard Library and exceptions to use this class..
"extrgexp.cpp", line 43: Error: RWCRExpr is not defined.
"extrgexp.cpp", line 43: Error: Cannot use const char* to initialize int.
"extrgexp.cpp", line 45: Error: match is not a member of RWCString.
The 3 error are generated as a result of the warning which results from RW_NO_STL being defined in compiler.h . To get the definition of RWCRExpr requires RW_NO_STL to be undefined. I've read previous threads and these seem to suggest that I needed to use the -compat switch. I have tried this and get the same result so I examined compiler.h, the relevant bit is
#if __SUNPRO_CC == 0x420 || __SUNPRO_CC_COMPAT == 4
# define RW_NO_STL 1
# define RW_NO_TYPENAME 1
# define RW_HEADER_WITH_EXTENSION 1
# define RW_NO_IO_SENTRY 1
# define RW_NO_IOSTD 1
#endif
#if __SUNPRO_CC_COMPAT == 5 || __SUNPRO_CC_COMPAT == 6
# define RW_NO_STL 1
/* # define RW_NO_UNBUFFERED 1 */
/* # define RW_STD_RELOPS_IN_NAMESPACE 1 */
# define RW_NO_IO_SENTRY 1
# define RW_NO_IOSTD 1
#endif
strikes me that whatever compat option I choose RW_NO_STL will be defined. Has anyone had more luck than me on this example
cheers
Gareth

If I read between the lines, it looks like you expect \b to match a blank character, right?
According to man re_format:
the bracket expressions `\[\[:<:\]\]' and `\[\[:>:\]\]' match the null string at the beginning and end of a word respectively.
Therefore, this seems to be what you're after:
sed -E -e 's/\[\[:<:\]\]in/aaa/g' testfile
The same man page states that \[:upper:\] and \[:lower:\] are the appropriate tags for upper and lowercase characters, respectively

Similar Messages

  • Extended Replace with Regular Expressions

    I am trying to figure out how to user regular expressions in
    HomeSite 5.5 extended search and replace.
    I am trying to find all matches to: <span
    class="someClass">FooText</span>
    And replace with: <sometag>FooText</sometag>
    I have been able to get the find part working with reg ex:
    <span class=\"someClass\">*[A-Za-z0-9_
    ><.="']*</span>
    However, I have not been able to figure out what to put in
    the replace box. I have tried different combinations of syntax with
    "\1" for the first match of the reg ex in the search field, but
    nothing has worked.
    Can someone help me out with the syntax for what I should
    enter in the replace field?

    SQL>with t as(
      2   select 1 id,'a   aa ---- ss-ee -' str from dual union
      3   select 2, 'a        aa -------- ss-ee ---- - - -' str from dual union
      4   select 3, '-' str from dual union
      5   select 4, '----- -- -a -' str from dual union
      6   select 5, '-a-a-a-a----a-a-a-' str from dual
      7  )
      8  select id,
      9  str,
    10  trim(trim('-' from regexp_replace(str, '( |-){2,}', '\1'))) new_str,
    11  length(str) len,
    12  length(trim(trim('-' from regexp_replace(str, '( |-){2,}', '\1')))) new_len
    13  from t;
    ID STR                                 NEW_STR                      LEN          NEW_LEN
      1 a   aa ---- ss-ee -                 a aa ss-ee                    19               10
      2 a     aa -------- ss-ee ---- - - -  a aa ss-ee                    34               10
      3 -                                                                  1
      4 ----- -- -a -                       a                             13                1
      5 -a-a-a-a----a-a-a-                  a-a-a-a-a-a-a                 18               13

  • [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 over objects?

    Hello everybody,
    following problem: I'm working on a project related to natural language processing and I need to match patterns against sentences. The patterns would be like the following example: "<NOUN> is just <VERB> with <NOUN> (and <CONNECTIVE> <NOUN>)*". Thus, each token in the regexp represents either a word or a class of words. Each token (word) would be represented as an object and it is possible to define equality relation on these objects. Now, does anybody here know about a regexp library, which would allow this? All the regexp libraries I've seen sofar are only working on a text. But I need a library, which would work on sequencies of objects, and the programmer would provide a method saying whether two objects are equal or not. Is there any such library? I don't have time to write it for myself.

    Actually, I think you need EBNF not regex.
    EBNF - Extended Backus-Naur Form - deals with definitions which include synbols which then have their own definitions. A 'rule' is a mapping from a 'symbol' to an 'expression'. A set of rules is known as a 'grammar'. Some of the expressions could contain regex if it respresents a String.
    regex - Regular Expressions - are just for text patterns.
    I haven't seen any EBNF (or BNF) programs, but I haven't searched too much for them either. Hopefully this will help point you toward more successfull searches.
    I have written some EBNF representations in Java, but they were for specialized uses with other code as part of the classes and so they could be applied generally to your needs.

  • Regular expression checker

    hi,
    i am new to regular expression. i would like to know if there is a tool to check regular expressions? the tool should based on the entered regular expression display the result.
    thanks

    import java.util.regex.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class JavaRegxTest extends JFrame implements ActionListener{
      JTextField regxInput, textInput;
      JButton doMatchButton, resetButton, exitButton;
      JTextArea resultsArea;
      public JavaRegxTest(){
        super("JavaRegxTest");
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        Container cp = getContentPane();
        cp.setLayout(new GridLayout(2, 1));
        JPanel upPanel = new JPanel(new GridLayout(5, 1));
        upPanel.add(new JLabel("regular expression:   "));
        upPanel.add(regxInput = new JTextField(50));
        upPanel.add(new JLabel("sample text:          "));
        upPanel.add(textInput = new JTextField(50));
        JPanel buttonPanel = new JPanel(new GridLayout(1, 3));
        buttonPanel.add(resetButton = new JButton("RESET"));
        buttonPanel.add(doMatchButton = new JButton("MATCH"));
        buttonPanel.add(exitButton = new JButton("EXIT"));
        upPanel.add(buttonPanel);
        resetButton.addActionListener(this);
        doMatchButton.addActionListener(this);
        exitButton.addActionListener(this);
        resultsArea = new JTextArea(20, 60);
        resultsArea.setEditable(false);
        JScrollPane jsp = new JScrollPane(resultsArea);
        cp.add(upPanel);
        cp.add(jsp);
        setSize(550, 700);
        setVisible(true);
      public void actionPerformed(ActionEvent e){
        JButton btn = (JButton)(e.getSource());
        if (btn == exitButton){
          System.exit(0);
        else if (btn == resetButton){
          reset();
        else if (btn == doMatchButton){
          doMatch();
      /* clear text */
      void reset(){
        regxInput.setText("");
        textInput.setText("");
        resultsArea.setText("");
      /* display match results */
      void doMatch(){
        resultsArea.setText(resultsArea.getText() + "REGX=" + regxInput.getText()
         + "\n" + "TEXT=" + textInput.getText() + "\n");
        try{
          Pattern pat = Pattern.compile(regxInput.getText());
          String sampleText = textInput.getText();
          Matcher mat = pat.matcher(sampleText);
          int gc = mat.groupCount();
          for (int i = 0; i <= gc; ++i){ //for each capture group
            resultsArea.setText(resultsArea.getText()
             + "GROUP" + i + " : \n"); //GROUP0 == whole match
            while (mat.find()){ //display every matched parts
              resultsArea.setText(resultsArea.getText()
               + " " + mat.group(i) + "\n");
            mat.reset(sampleText); //go to next group
        catch(Exception e){
          resultsArea.setText(e.toString());
      public static void main(String[] args){
        JavaRegxTest jrt = new JavaRegxTest();
    }

  • Regular expression and XML

    Hello,
    I have an XML file containing regular expressions and i parse the file, extract the pattern from it and search for it using java regex package. The problem is it works fine when patterns are words but when the pattern is something like
    write \\d+ (write followed by a space followed by one or mre digits) it doesn't work.
    I wrote the same code but with the pattern embedded in it,ie. without using XML and it worked. But when extracting with XML it fails.
    Also if the pattern is write[0-9] it only extracts write[0-9 and gives an error of no closing bracket.
    Could anyone please tell me what i am missing out
    Thank you

    thank you for your replies. Well i have still no got over the problem so i am posting my code here and hoping it can get solved
    import org.xml.sax.*;
    import org.xml.sax.helpers.*;
    import java.io.*;
    import java.util.regex.*;
    class textextractor extends DefaultHandler{
         boolean regex=false;
    public void startElement(String namespaceURI,String localName,String qn,Attributes attr)
              if(localName.equals("REGEX"))
               regex=true;
    public void characters(char [] text,int start,int length)throws SAXException {
              String t=new String(text,start,length);
              boolean flag=false;
              if(regex==true)
                Pattern pattern;
                  String w=new String(t);
              pattern = Pattern.compile(w);
              Matcher matcher;
              matcher=pattern.matcher("there is a bat   read  write 13    error at line ");
              while(matcher.find())
               flag=true;
               System.out.println("I found the text \"" + matcher.group() +"\" starting at index "
               + matcher.start() +"and ending at index " + matcher.end() + ".");
             if(!flag)
               System.out.println("not found");
             regex=false;
    public class saxt2 {
         public static void main(String args[]) {
              try {
                    XMLReader parser= XMLReaderFactory.createXMLReader();
                    ContentHandler handler=new textextractor();
                    parser.setContentHandler(handler);
                                    parser.parse("d:\\regex.xml");
                  }catch (Exception e) {
                   System.err.println(e);
    }The xml file is
                      <RegularExpression>
                      <REGEX>write</REGEX>
                      <REGEX>write \\d+</REGEX>
                      <REGEX>read[0-9]</REGEX>
                      </RegularExpression>by running the code you can see that write is found,write \\d+ doesn't match write 13 in the string and read[0-9] gives and error.
    Any help will be greatly appreciated

  • AppleScript Regular expression

    Hi all,
    I'm using BBEdit and run an AppleSript (for the very first time) that looks as follows:
    tell application "BBEdit"
      activate
              set bounds of find window to {1143, 81, 1769, 266}
      -- open file
              set theAlias to choose file
              set theDoc to open theAlias
              replace "P2Schedule:put_batch_calculator_on" using "<a href=\"http://www.p2engine.com/p2schedule/put_batch_calculator_on\">P2Schedule:put_batch_calculator_off</a>" searching in text 1 of theDoc options {search mode:literal, starting at top:true, wrap around:false, backwards:false, case sensitive:false, match words:false, extend selection:false}
    end tell
    What it does is: it replaces the text P2Schedule:put_batch_calculator_on by a weblink to a webpage (including the text on the screen).
    I have a lot of functions like these. They all look like this: P2Schedule:name_of_function.
    Can someone help me how to do this.
    So:
    Replace
    P2Schedule:name_of_function
    by
    "<a href=\"http://www.p2engine.com/p2schedule/name_of_function\">P2Schedule:name_of_function</a>
    I'm new to scripting, so simple explanation is welcome :-)
    Mario

    following your use of BBEdit you'd want something like this:
    set functionNames to {"put_batch_calculator_on", "some_other_function", "and_a_third_function"}
    tell application "BBEdit"
      activate
              set bounds of find window to {1143, 81, 1769, 266}
      -- open file
              set theAlias to choose file
              set theDoc to open theAlias
              repeat with thisFunctionName in functionNames
                        replace "P2Schedule:" & thisFunctionName using "<a href=\"http://www.p2engine.com/p2schedule/" & thisFunctionName & "\">P2Schedule:" & thisFunctionName & "</a>" searching in text 1 of theDoc options {search mode:literal, starting at top:true, wrap around:false, backwards:false, case sensitive:false, match words:false, extend selection:false}
              end repeat
    end tell
    (I user TextWrangler to check the syntax, but it should be the same).  this loops through a list of function names and changes them.
    However, if you need to the regular expressions in applescript, I strongly suggest that you download and install the Satimage osax.  it will be significantly faster, and its syntax is somewhat easier than BBEdit's.  that would look something like this:
    set theAlias to choose file
    set fp to open for access theAlias with write permission
    set originalText to read fp
    --following requires Satimage osax
    set revisedText to change "P2Schedule:([^: ]+)" into "<a href=\"http://www.p2engine.com/p2schedule/\\1\">P2Schedule:\\1</a>" in originalText with regexp without case sensitive
    write revisedText to fp
    close access fp
    where I've guessed the ending delimiter is either a space or a colon (change [^: ]+ to capture the correct delimiter, if different, using standard rexexp rules).

  • Dumbfounded by Scanner processing String using regular expression

    I was reading Bruce Eckel's book when I came across something interesting: extending Scanner with regular expressions. Unfortunately, I was confronted with an issue that doesn't make much sense to me: if the String that I am scanning contains a hyphen, the Scanner doesn't produce anything. As soon as I take it out, it all works like a charm. Here is my example:
    import java.util.Scanner;
    import java.util.regex.*;
    public class StringScan {
    public static void main (String [] args){
         String input = "there's one caveat when scanning with regular expressions";
         Scanner scanner = new Scanner (input);
         String pattern = "[a-z]\\w+";
         while (scanner.hasNext(pattern)){
              scanner.next(pattern);
              MatchResult match = scanner.match();
              String output = match.group();
              System.out.println(output);
    }What could be the reason? I imagined it could be because the hyphen for some reason gets given a special meaning but when I tried escaping it, it still didn't work.

    Thanks for your prompt reply.
    I have figured out what was wrong with my code, by the way. Since a single quote is not a word character, it does not match w+. And as the very first input token does not match, the scanner stops immediately. I rewrote my regex to "[a-z].*" and now it does work.

  • Password validation with regular expression

    I'm trying to use a regular expression to validate a password. I've tried a number of different regex's that seem to work elsewhere but do not work in HTML DB. This includes a couple that I wrote and that I found on regex web sites. Specifically, I'm trying to validate that a string has:
    1. at least one special character
    2. at least one numeric character
    3. no more than 6 consecutive characters
    4. has a length between 8 and 14
    Does anyone know why some regular expressions do not work in HTML DB that work elsewhere or has anyone done a regex similar to this in HTML DB.
    Thanks!
    - Brian

    I see, I will use the [0-9] instead. The expression still does not work though. I simplified the expression down to try and figure out what doesn't work and it seems like it's the "?=".
    1. I first entered the expression:
    ([:alnum:]*[0-9])
    This expression just says there must be a number and it works fine in HTML DB.
    2. I extended it to:
    ([:alnum:]*[0-9])([:alnum:]*[a-z])
    This expression says that there must be a number followed by a letter. In this example "1a" works but "a1" does not.
    3. To make it not care about the order I would normally add "?=" like so:
    (?=[:alnum:]*[0-9])(?=[:alnum:]*[a-z])
    This should work for "a1" or "1a" because the ? says the order doesn't matter. When I try this in HTML DB neither "1a" or "a1" work.
    Any ideas?
    Thanks
    - Brian

  • Regular expression: check for the presence of special characters.

    I have the following requirement:
    I need to check for the presence of the following characters in a keyword: @, #, > if any of these characters are present, then they need to be stripped off, before going further. Please let me know the regular expression to check for these characters.

    I am trying to extend the same logic for the following characters:
    .,‘“?!@#%^&*()-~<>[]{}\+=`©® . here is the code fragment:
    Pattern kValidator = Pattern.compile("[\\.,\\‘\\“?!@#%^&*()-~<>[]{}\\+=\\`©®]");
    Matcher kMatcher = kValidator.matcher(keyWord);
    if (kMatcher.find(0)) {
    keyWord = keyWord.replaceAll("[.,\\‘\\“?!@#%^&*()-~<>[]{}\\+=\\`©®]", " ");
    }I get the following error. This error is from the weblogic command window. I dont understand these special characters.
    Error:
    28 Oct 2008 12:27:48 | INFO  | SearchController   | Exception while fetching search results in controller:Unclosed character class near index
    39
    [\.,\&#915;Çÿ\&#915;Ç£?!@#%^&*()-~<>[]{}\+=\`&#9516;&#8976;&#9516;«]
                                           ^
    java.util.regex.PatternSyntaxException: Unclosed character class near index 39
    [\.,\&#915;Çÿ\&#915;Ç£?!@#%^&*()-~<>[]{}\+=\`&#9516;&#8976;&#9516;«]
                                           ^
            at java.util.regex.Pattern.error(Pattern.java:1650)
            at java.util.regex.Pattern.clazz(Pattern.java:2199)
            at java.util.regex.Pattern.sequence(Pattern.java:1727)
            at java.util.regex.Pattern.expr(Pattern.java:1687)
            at java.util.regex.Pattern.compile(Pattern.java:1397)
            at java.util.regex.Pattern.<init>(Pattern.java:1124)
            at java.util.regex.Pattern.compile(Pattern.java:817)

  • Safari May Not Interpret Regular Expression in Compliance with W3C Standard

    We are troubleshooting why some websites are no longer working when rendered with the Safari 2.0.4 browser. The failure begins when client entered data is validated using regular expressions.
    We have localized the issue to Safari's not interpretting regular expressions consistently.
    For example:
    Does the regex \u00e9 match the literal character é? (Validates the regular expression engine understands Unicode escape sequences for extended characters.)? - NO, but it does on IE and FireFox
    Does the regex \u0041 match the literal character A? (Validates the regular expression engine understands Unicode escape sequences for ASCII characters.)? - NO, but it does on IE and FireFox
    Does the regex é match the literal character é? (Validates the regular expression engine understands literal characters outside the ASCII range – this is against ECMAScript spec.)? - Sometimes, but always on IE and FireFox
    Write a Unicode escape sequence to the screen on the client side. (Validates the string parsing and display in the JS engine works.) - Works on all 3
    Is escape sequence \u00e9 equivalent to literal character é? (Validates the string functionality in the JS engine works with extended characters.)? Yes on all 3.
    Is escape sequence \u0041 equivalent to literal character A? (Validates the string functionality in the JS engine works with ASCII characters.)? Yes on all 3
    Does the regex A match the literal character A? (Validates the regular expression engine understands literal characters in the ASCII range – this is ECMAScript spec.)? Yes on all 3
    Please help. It's hard for me to believe that the regular expression / javascript interpreter(s) for Safari aren't working as they have in the past - but all roads are pointed that way....
    Thank you for your review.
      Mac OS X (10.4.7)  

    We are troubleshooting why some websites are no longer working when rendered with the Safari 2.0.4 browser. The failure begins when client entered data is validated using regular expressions.
    We have localized the issue to Safari's not interpretting regular expressions consistently.
    For example:
    Does the regex \u00e9 match the literal character é? (Validates the regular expression engine understands Unicode escape sequences for extended characters.)? - NO, but it does on IE and FireFox
    Does the regex \u0041 match the literal character A? (Validates the regular expression engine understands Unicode escape sequences for ASCII characters.)? - NO, but it does on IE and FireFox
    Does the regex é match the literal character é? (Validates the regular expression engine understands literal characters outside the ASCII range – this is against ECMAScript spec.)? - Sometimes, but always on IE and FireFox
    Write a Unicode escape sequence to the screen on the client side. (Validates the string parsing and display in the JS engine works.) - Works on all 3
    Is escape sequence \u00e9 equivalent to literal character é? (Validates the string functionality in the JS engine works with extended characters.)? Yes on all 3.
    Is escape sequence \u0041 equivalent to literal character A? (Validates the string functionality in the JS engine works with ASCII characters.)? Yes on all 3
    Does the regex A match the literal character A? (Validates the regular expression engine understands literal characters in the ASCII range – this is ECMAScript spec.)? Yes on all 3
    Please help. It's hard for me to believe that the regular expression / javascript interpreter(s) for Safari aren't working as they have in the past - but all roads are pointed that way....
    Thank you for your review.
      Mac OS X (10.4.7)  

  • Find text Between tags with a Regular Expression

    I am trying to find specif text -- table names - within a
    <cfquery> tag in all my cfm files. I am using an extend find
    function in Homesite (I think Dreamweaver has the same
    functionality). This expression works:
    <[Cc][fF][qQ][uU][eE][rR][Yy]
    [^>]*>[^>]*(EventName|AttendeeName)[^>]*</[Cc][fF][qQ][uU][eE][rR][Yy]>
    for find the text EventName or AttendeeName. However, if
    there are other cf tags like <cfif> within the
    <cfquery>, then the tag/text is not found.
    Can anyone help? It is a useful expression to have if you are
    trying to transfer applications developed on a windows machine to
    a, say, linux machine, and have table name sensititvity issues with
    mySql.

    quote:
    Originally posted by:
    Newsgroup User
    Thanks for all the help. Comments below.
    > Thanks, but it:
    > 1) Captures everything between the first and last query
    in a script if there
    > is more than one cfquery in the script
    Oops: sorry. Stick a question mark after the asterisks to
    stop the matches
    being greedy.
    Used this:
    <[Cc][fF][qQ][uU][eE][rR][Yy].*?(EventName|AttendeeName)[^>].*?</[Cc][fF][qQ][uU][eE][rR][ Yy]>
    and got some finds again with multiple queries and some
    errors as mentioned below.
    > 2) It produces some regular expression errors in
    Homesite.
    Can't help you there. Sounds like HS's regex processor is
    bung: there's
    nothing non-standard or tricky about that regex (which might
    cause
    compatibility issues; JS vs PERL vs Java, etc).
    HS on the whole is bung (IMO). Have you considered using a
    text editor
    that is... err... *current*? ;-)
    No, can you suggest one. Just use HS for years and it does
    most of what I want.
    What sort of errors is it giving?
    Regular expression error No 17. Bad expression format or
    internal error.
    > The reason for this is I am developing on a windows
    machine with mysql and
    > want to use the application online on a linux machine
    where table names are
    > case sensitive. My code was not always faithful to that
    since in windows you
    > can be sloppy!
    Have you seen this:
    http://dev.mysql.com/doc/refman/5.0/en/identifier-case-sensitivity.html
    It might be a better approach anyhow.
    Adam

  • How to include a forward slash(/) in my regular expression

    Hai All,
    I am having a regular expression which should accept only A-Z, 0-9, (underscore) and .(period) .
    <property name="patterns" value="[A-Z0-9\\._]*" />
    Now i need to add /(Forward slash) to this expression.
    <property name="patterns" value="[A-Z0-9\\._/]" />
    But when i add it it is accepting both Foward slash and Backward slash.
    Can someone guide me such that it accepts only A-Z, 0-9, Underscore, period and a Forward slash(/).
    Thx in advance..

    Looks like you had it right to me.
    import java.util.regex.Pattern;
    import junit.framework.TestCase;
    public class RegexTest extends TestCase{
         public String patternString = "[A-Z0-9\\./]*";
         public void testRegex(){
              Pattern pattern = Pattern.compile(patternString);
              assertTrue(Pattern.matches(patternString, "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"));
              assertFalse(Pattern.matches(patternString, "abc"));
              assertTrue(Pattern.matches(patternString, "24.7"));
              assertTrue(Pattern.matches(patternString, "24/7"));
              assertFalse(Pattern.matches(patternString, "21\\7"));
    }It works in my tests.
    What happends to this "patterns" property? Where and how are you using it?

  • Logical AND in Java Regular Expressions

    I'm trying to implement logical AND using Java Regular Expressions.
    I couldn't figure out how to do it after reading Java docs and textbooks. I can do something like "abc.*def", which means that I'm looking for strings which have "abc", then anything, then "def", but it is not "pure" logical AND - I will not find "def.*abc" this way.
    Any ideas, how to do it ?
    Baken

    First off, looks like you're really talking about an "OR", not an "AND" - you want it to match abc.*def OR def.*abc right? If you tried to match abc.*def AND def.*abc nothing would ever match that, as no string can begin with both "abc" and "def", just like no numeric value can be both 2 and 5.
    Anyway, maybe regex isn't the right tool for this job. Can you not simply programmatically match it yourself using String methods? You want it to match if the string "starts with" abc and "ends with" def, or vice-versa. Just write some simple code.

  • Help in Regular expression

    Hello..
    I wanted to write a regular expression to match the foll string..
    <!--endclickprintexclude--><!--startclickprintexclude--> <!--endclickprintexclude-->
    <p> <b>NEW ORLEANS, Louisiana (CNN) </b>
    -- Two years after Hurricane Katrina devastated coastal areas of Louisiana and Mississippi, residents say much of America has forgotten their plight.
    </p> <!--startclickprintexclude-->
    I tried doing..
    Matcher matcher= Pattern.compile("<!--endclickprintexclude--> <p><b>([^<^>]+?)</p><!--startclickprintexclude-->", Pattern.CASE_INSENSITIVE).matcher(story);
    Its not working...
    is there any other soln?

    Theres probably a better way to do this but here's a way that works.
    import java.util.regex.*;
    public class RegexTester{
    public static void main(String[] args){
         String text =
         "<!--endclickprintexclude--><!--startclickprintexclude--> <!--endclickprintexclude-->" +
         "<p> <b>NEW ORLEANS, Louisiana (CNN) </b>" +
         "-- Two years after Hurricane Katrina devastated coastal areas of Louisiana and Mississippi," +
         "residents say much of America has forgotten their plight." +
         "</p> <!--startclickprintexclude-->";
         String regex = ">((?:\\s*[\\S&&[^<>]]+\\s*)*?)<";
         Pattern p = Pattern.compile(regex);
         Matcher m = p.matcher(text);
         while(m.find()){
         System.out.println("Match: '" + m.group(1) + "'");
    }

Maybe you are looking for

  • Unable to Validate this serial number

    Okay, so after the problems with trackpads on Yosemite, I decided to upgrade my Photoshop Elements... purchased, I have a valid order number (AD002567702UK), and a serial number, but get a validation errors. I have wasted two hours trying to get this

  • [solved] Running HPGCC on a 64bit install

    Hi, I've bought a HP 50g and I'd like to "play" a little with HPGCC but it's precompiled as a 32bit binary. I realize I can run 32bit binaries on a 64 bit install if I install some lib32-* packages, but I don't know which ones to install. Can anyone

  • File transfer, read write through sockets in client server programming java

    Hello All, need help again. I am trying to create a Client server program, where, the Client first sends a file to Server, on accepting the file, the server generates another file(probably xml), send it to the client as a response, the client read th

  • Windows Azure Active Directory Sync Setup

    Hi, Currently trying to install Windows Azure Active Directory Sync tool for use with Office 365. After five attempts to install the Sync Tool, I finally had some luck, now I am configuring the Sync tool and have been given the following error "A con

  • Put sim card in iphone 3 or 3g

    is it possible to put an active sim card from another ATT phone into the Iphone 3 or 3g and use the iphone as your "new" phone? do i need a data package in order to use the iphone internet? if so, can i use the same $15 data package i have on the old