gcue

stringregexp match

11 posts in this topic

hello

i am trying to pull the test from this line but i am just getting Last Keyword XMP

$string = "Last Keyword XMP                : test"
ConsoleWrite(StringLeft(StringRegExpReplace($string, "Last Keyword XMP.*?(\d.+)", "$1"), 16) & @CRLF)

thank you in advance!

Share this post


Link to post
Share on other sites
$string = "Last Keyword XMP                : test"
ConsoleWrite(StringRegExp($string , "\s+:\s+(.*\z)" , 3)[0] & @CRLF)

 


,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

beautiful!

thank you!

Share this post


Link to post
Share on other sites

very welcome,  as well without regexp (provided the colon is always there)

consolewrite(stringstripws(stringmid($string , stringinstr($string , ":" , 0 , -1) + 1) , 1) & @CRLF)

 


,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

:)

$string = "Last Keyword XMP                : test"
Msgbox(0, "", StringRegExp($string , '\w+$' , 1)[0])

 

Share this post


Link to post
Share on other sites

short and sweet

thank you!

Share this post


Link to post
Share on other sites

i tried to use it (tried switching with a V to accept anythign that isnt a vertical whitespace character) with this but it didnt work even if i took out the comma

$string = "GPS Position                    : 75 deg 7 41.99 N, 118 deg 3 37.21 W"
ConsoleWrite(StringRegExp($string, '\V+$', 1)[0] & @CRLF)

 

Share this post


Link to post
Share on other sites

Do you agree when I say that  "75 deg 7 41.99 N, 118 deg 3 37.21 W"  is a little different string than  "test" ?
:)

$string = "GPS Position                    : 75 deg 7 41.99 N, 118 deg 3 37.21 W"
ConsoleWrite(StringRegExp($string, ':\h*([^:]+)$', 1)[0] & @CRLF)

 

Share this post


Link to post
Share on other sites

haha yes.. thats why i thought V would work since it means anythign non white vertical character

lol

Share this post


Link to post
Share on other sites

thanks jguinch!

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now