AlienStar Posted December 4, 2018 Share Posted December 4, 2018 hello everybody first I read many examples but nothing help! I have this string: Quote Company name: galaxy-1 Address: 1st. sq, - build 1 Tel: 011-2333 - 055-2213 Fax: 033-11124423 all I need is to delete "-" which is included in numbers only! so I need this result: Quote Company name: galaxy-1 Address: 1st. sq, - build 1 Tel: 0112333 - 0552213 Fax: 03311124423 If I used StringReplace function it replace all "-", not as above please help Link to comment Share on other sites More sharing options...
TheXman Posted December 4, 2018 Share Posted December 4, 2018 (edited) Here's one of many ways that it can be done: Example() Func Example() Local $sBefore = _ "Company name: galaxy-1" & @CRLF & _ "Address: 1st. sq, - build 1" & @CRLF & _ "Tel: 011-2333 - 055-2213" & @CRLF & _ "Fax: 033-11124423" & @CRLF Local $sAfter = StringRegExpReplace($sBefore, "\b(\d+)-(\d+)\b", "\1\2") ConsoleWrite("Before:" & @CRLF & $sBefore) ConsoleWrite(@CRLF) ConsoleWrite("After:" & @CRLF & $sAfter) EndFunc Output: Before: Company name: galaxy-1 Address: 1st. sq, - build 1 Tel: 011-2333 - 055-2213 Fax: 033-11124423 After: Company name: galaxy-1 Address: 1st. sq, - build 1 Tel: 0112333 - 0552213 Fax: 03311124423 Edited December 4, 2018 by TheXman AlienStar and IAMK 2 CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
AlienStar Posted December 4, 2018 Author Share Posted December 4, 2018 3 hours ago, TheXman said: Here's one of many ways that it can be done: Example() Func Example() Local $sBefore = _ "Company name: galaxy-1" & @CRLF & _ "Address: 1st. sq, - build 1" & @CRLF & _ "Tel: 011-2333 - 055-2213" & @CRLF & _ "Fax: 033-11124423" & @CRLF Local $sAfter = StringRegExpReplace($sBefore, "\b(\d+)-(\d+)\b", "\1\2") ConsoleWrite("Before:" & @CRLF & $sBefore) ConsoleWrite(@CRLF) ConsoleWrite("After:" & @CRLF & $sAfter) EndFunc Output: Before: Company name: galaxy-1 Address: 1st. sq, - build 1 Tel: 011-2333 - 055-2213 Fax: 033-11124423 After: Company name: galaxy-1 Address: 1st. sq, - build 1 Tel: 0112333 - 0552213 Fax: 03311124423 it works fine thaaaanks so much Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now