0

I need a help to finish a Perl Regex to the context below:

[a-zA-Z:]

------------------------------------------
I have                      I need
------------------------------------------
> str(datasets::ris$)       datasets::ris
> plot(datasets::iris$      datasets::iris
str(datasets::iris$)        datasets::iris
plot(datasets::iris$        datasets::iris
str(iris$)                  iris
plot(iris$                  iris
plot(IRIs$                  IRIs
iris$                       iris
------------------------------------------

http://rubular.com/r/kyLAy679Ql

Thanks,

jcfaria
  • 312
  • 3
  • 14

2 Answers2

1

The results are at http://rubular.com/r/IgInzqrwwX

You just need to add a lookahead to your regex [a-zA-Z:]+(?=\s*\$)

0

You can use this regex with an optional match and capturing group. Your desired text is available in captured group #1:

/(?:[^(\n]*\()?([a-zA-Z:]+)/

Rubular Demo

anubhava
  • 761,203
  • 64
  • 569
  • 643
  • All match groups is OK: thanks. But how can I get it? I'm under Delphi and using pcre. sTmp:= RegEx(string, '(?:[^(\n]*\()?([a-zA-Z:]+)', False); ShowMessage(sTmp); – jcfaria Apr 29 '16 at 23:41
  • Sorry I don't know Delphi but I am sure getting a captured group would be pretty straight forward as it is the most basic regex operation supported in all the regex flavors. – anubhava Apr 30 '16 at 04:51