d112

stringregexp problem

6 posts in this topic

#1 ·  Posted

Hi everyone,

I'd like to ask here my question because I tried myself without success with StringRegExp for the last 2 hours

I have a string like this:

" abc defgh jklm "

and I want to return an array like this:

$array[0]="abc"

$array[1]="defgh" 

$array[2]="jklm"

Can anyone give me some help please?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

#include <array.au3>
#include <StringConstants.au3>

$s_Test = " abc defgh jklm "
$as_Array = StringRegExp($s_Test, '[a-z]{3,}', $STR_REGEXPARRAYGLOBALMATCH)
_ArrayDisplay($as_Array)

 

Edited by benners

Share this post


Link to post
Share on other sites

#4 ·  Posted

thank you, it works

I only changed 

[a-z]

with

[a-z,A-Z,0-9]

 

Share this post


Link to post
Share on other sites

#5 ·  Posted

4 minutes ago, d112 said:

thank you, it works

I only changed 

[a-z]

with

[a-z,A-Z,0-9]

 

If you use the code that jguinch left, you don't have to bother with that. It will match anything that isn't a space. It's better than mine.

Share this post


Link to post
Share on other sites

#6 ·  Posted

unless there are other criteria, with no regex:

#include<array.au3>

$s_Test = " abc defgh jklm "
_ArrayDisplay(stringsplit(stringstripws($s_Test , 3) , " " , 2))

 


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

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