Forum Discussion
jgranieri_42214
Nimbostratus
Jul 29, 2015Need to apply regex to a variable
Hello,
I have a need for regex to find the 2nd occurrence of a character and capture the data until the end. I tested my regex here and confirmed this regex will do what I need it to "[^@]+$". M...
Kevin_Stewart
Employee
Jul 29, 2015You're actually pretty close:
when RULE_INIT {
set logon "jeff@test1@bank1"
regexp {[^@]+$} $logon result
log local0. $result
}
But you might be better off avoiding the regex with something more robust. Here's a few example options:
when RULE_INIT {
set logon "jeff@test1@bank1"
scan $logon {%*[^@]@%*[^@]@%s} result
log local0. $result
}
or:
when RULE_INIT {
set logon "jeff@test1@bank1"
set result [string range $logon [expr [string last "@" $logon] +1] end]
log local0. $result
}
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects