RegEx-library - Split ?

moster67

Expert
Licensed User
Longtime User
Erel:

Any chance the split-method can be added to the RegEx-library?

By having a look at

Regex.Split Method

it seems like it is supported by the NET Compact Framework

I guess another solution could be to use the Door-library but I must admit that I am so overwhelmed by all this new stuff that I haven't read through all the documentation for the Door-library.

EDIT: Sorry I guess that this post should have been posted in the Wishlist-part of the forum. Erel - can you move it there?

Rgds,
moster67
 
Last edited:

moster67

Expert
Licensed User
Longtime User
You are probably right that StrSplit would be sufficient for most tasks.

I am currently working on a spell-checker and I am reading a lot of articles how to implement various things and the ideas behind. It's very interesting and I am learning a lot. While my primitive spell-checker for the time being only checks words in a clean text-box, I have also been looking into the possibility to extract words to spell-check from web-pages which would involve HTML-parsing. I have no problem admitting that I study code-fragments found on the internet which I can benefit from. I have seen many examples for HTML-parsing that uses RegEx (matching-patterns) and then the split-method for extracting words.

And then the other other day I came across so called "camelCase words" (look it up on wikipedia) and a function for analysing said words which involves the split-method.

As you said, most things can surely be resolved by using the ordinary StrSplit but since you have already written a RegEx-library, why not extend it further including also the split-method? It would surely make it easier for me to port certain functions for use within Basic4PPC.

In any case, I will have a look at the Door-library and see if I can access the split-method through it.

rgds,
moster67



Can you describe a situation where StrSplit will not be sufficient?
 

agraham

Expert
Licensed User
Longtime User
In any case, I will have a look at the Door-library and see if I can access the split-method through it.

Like this
B4X:
Sub Globals
   'Declare the global variables here.
   Dim a(0)
End Sub

Sub App_Start
   'Form1.Show
   regobj.New1(False)
   
   regex1.New1(",")
   regobj.FromLibrary("regex1", "reg", B4PObject(2)) ' version <= 6.30
   'regobj.FromLibrary("_main_regex1", "reg", B4PObject(2)) ' version >= 6.42
   str = "split, this, string"
   a() = regobj.RunMethod2("Split", str, "System.String")   
   Msgbox(a(0) & a(1) & a(2))
End Sub
 
Last edited:

moster67

Expert
Licensed User
Longtime User
Thank you Agraham! Really appreciated!

It works great. I will now try it out in a sample-application I've written. A good example like yours will now make it easier for me to further explore the possibilites of the Door-library.

Just in case it's not clear for other users:
-in order to run the below example, kindly furnished by Agraham, you need to add the Door-library and the RegEx-library to your project.

rgds,
moster67

Like this
B4X:
Sub Globals
   'Declare the global variables here.
   Dim a(0)
End Sub

Sub App_Start
   'Form1.Show
   regobj.New1(False)
   
   regex1.New1(",")
   regobj.FromLibrary("regex1", "reg", B4PObject(2)) ' version <= 6.30
   'regobj.FromLibrary("_main_regex1", "reg", B4PObject(2)) ' version >= 6.42
   str = "split, this, string"
   a() = regobj.RunMethod2("Split", str, "System.String")   
   Msgbox(a(0) & a(1) & a(2))
End Sub
 

agraham

Expert
Licensed User
Longtime User
this code will also work in the new version.
Hi Erel, I don't understand :confused:. It does work in the new version using the line commented out in the code above. Do you mean that the next Door library will accept "Main.Regex1" or just "Regex1" as an object name in the new version?
 

agraham

Expert
Licensed User
Longtime User
I am afraid we have a misunderstanding due to the nuances of language in the use of tenses. :confused:
This line will work:
B4X:
regobj.FromLibrary("regex1", "reg", B4PObject(2))
It is the same case as with all runtime control keywords.
If no module was specified then the compiler implicitly adds the current module.
If you mean "will work at the moment with 6.42" then it doesn't because of the extra underscore the latest parser adds that the door library doesn't presently recognize.

If you mean "will work when I have updated the Door libray" then did you mean "It will be the same..." and "module is specified ... will add ..."?

Sorry to be pedantic (I'm not really :) as you all know by now!).
 
Top