Pages: 1
RSS
Replace string in regex
 
Hi. How can replace text in regex?
I have script for parsing email address.

%SetPattRegExp=_(.*)@(.*)_%-
%RegExpBlindMatch=_%FromAddr_%-
%SubPatt=_2_

but i want replace domain.tld to domain_tld

Thanks
Edited: True Friend - 15 June 2018 17:16:13
 
Please
 
I don't know if any RegEx specialists are reading here.

Maybe your question is not really specific to The Bat, and you can ask about it elsewhere? There must be forums that specialize in RegEx issues.

Good luck either way!
I volunteer as a moderator to help keep the forum tidy. I do not work for Ritlabs SRL.
 
Quote
Daniel van Rooijen wrote:
I don't know if any RegEx specialists are reading here.

Maybe your question is not really specific to The Bat, and you can ask about it elsewhere? There must be forums that specialize in RegEx issues.

Good luck either way!
This regex language is Python?  
 
No, RegEx is much older than Python. Python and many other languages do support RegEx, though.
I volunteer as a moderator to help keep the forum tidy. I do not work for Ritlabs SRL.
 
Quote
True Friend wrote:

but i want replace domain.tld to domain_tld
The Bat! provides the macro to automatically find all occurrences of the pattern defined as the regular ex * pression ("regexp") and replace it with the specified "new_text" in the "text" searched. A fourth argument n, which is the number of the matched subpattern, may be optionally supplied. As the "text" to be searched, the result of another macro can be used (for example,% OText). The syntax of this macro is following:
Code
%ReplaceRegExp("regexp", "new_text", "text"[, n])

So, your problem can be solved using the macro:
Code
%ReplaceRegExp("(?is)domain.tld", "domain_tld", "%OFromAddr")

Given macro returns the sender address with modified domain name. I use %OFromAddr macro here instead of %FromAddr because you want probably analyse incoming mail.
 
So, 'True Friend' -- Sygmunt offered you an extensive solution here ten days ago. Did it help you?
I volunteer as a moderator to help keep the forum tidy. I do not work for Ritlabs SRL.
Pages: 1