Source language: Translate to:

Next NeoBook Update Needs Regex

Post your suggestions for future versions of NeoBook

Moderator: Neosoft Support

Next NeoBook Update Needs Regex

Postby TMcD » Fri May 22, 2015 5:11 pm

I've been frustrated over the years and have had to do workarounds and that's "okay", but there have been projects I just stopped because of no real (deep) string handling...

I grab a lot of web pages and have to pull data out of them, and without a wildcard/Regex, it's just too time consuming to test multiple options, methods.

And I know NeoSoftware wants to grow, so NeoBook has to have more expected/mainstream tools/functionality built-in.

I'd love to be able to:

SearchStr */*/* in order to find a date of like 5/12/2015 within a string, but I'll settle for the more robust Regex for the longevity of NeoBook.
TMcD
 
Posts: 237
Joined: Sun Apr 10, 2005 11:20 am

Re: Next NeoBook Update Needs Regex

Postby Gaev » Fri May 22, 2015 6:18 pm

TMcD:

I'd love to be able to:

SearchStr */*/* in order to find a date of like 5/12/2015 within a string, but I'll settle for the more robust Regex for the longevity of NeoBook.

Are you open to using third party Plug-ins ? ... I think one/more of HPW, dec and David de Argentina has Regex functionality offered within one of their plug-ins.

Also, if you are familiar with use of Regex within javascript, have you considered writing a generic (javascript) Function that you could Call ? ... something like ...
Code: Select all
Call tmcdRegex "string to be searched" "regex string" "result variable"
User avatar
Gaev
 
Posts: 3728
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Re: Next NeoBook Update Needs Regex

Postby TMcD » Fri May 22, 2015 6:29 pm

The reason why I didn't mention plug-ins or getting further nerdy with JavaScript and why I still feel it needs to be a NATIVE part of NeoBook is because:

Parsing and manipulating data (strings in this case) is one of the major things any (final, en user) software has to, and must do.
(#2 is displaying data)
(#3 is interface)

* Not in any particular order, but the 3 things of software (as I see it). :)
TMcD
 
Posts: 237
Joined: Sun Apr 10, 2005 11:20 am

Re: Next NeoBook Update Needs Regex

Postby Gaev » Sat May 23, 2015 7:20 am

TMcD:

The reason why I didn't mention plug-ins or getting further nerdy with JavaScript and why I still feel it needs to be a NATIVE part of NeoBook is because:

I am confused.

a) If you have a fundamental business reason for not relying on third parties, it is understandable.

But from a technical point of view, what is the difference between using commands like ...

neobookRegex "string to be searched" "regex string" "result variable"

... and ...

hpwRegex "string to be searched" "regex string" "result variable"
decRegex "string to be searched" "regex string" "result variable"
etc.

b) you don't have to write the javascript function ... as long as you can Call one that does the job.

Or are you saying that you do not want to learn how to code the "regex patterns" ... and want NeoBook to provide "simplified search specifications that any non programmer type can request" ... if so, can you provide details (examples) of the type of request you would like to make for the different types of search requests you would want to make ?

Parsing and manipulating data (strings in this case) is one of the major things any (final, en user) software has to, and must do.
(#2 is displaying data)
(#3 is interface)

Can you elaborate with examples ?
User avatar
Gaev
 
Posts: 3728
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Re: Next NeoBook Update Needs Regex

Postby TMcD » Sat May 23, 2015 12:28 pm

Plain and simple:

1. Having been with Neobook for more than a decade, it has needed needed serious string handling for a long time.

2. I have seen TOO many plug-in developers come and go (or drop support), that I really only rely on NeoSostware. (And #1 again).

3. I know some Regex and can use Regex Buddy or some other tool easily to figure out what I need. And a command like this is all we need: RegEx "string" "Regexformula" "result"
TMcD
 
Posts: 237
Joined: Sun Apr 10, 2005 11:20 am

Re: Next NeoBook Update Needs Regex

Postby Gaev » Sat May 23, 2015 5:18 pm

TMcD:

Here is a solution that does not require a third party plugin ...

1) using notepad.exe (or similar text editor), create a file called gkRegex (no file extension) in the Functions folder where your NeoBook is installed ...
Code: Select all
{NeoBook Function}
Version=5.80
Language=JScript
Param=[%StringToBeSearched]|Text|String to be searched
Param=[%SearchPattern]|Text|Search Pattern
Param=[%Modifiers]|Text|Modifiers
Param=[%RegexResult]|Variable|Variable for Result of Regex operation
{End}
//gkRegex
thisString = "[%StringToBeSearched]";
thisRegexObject = new RegExp("[%SearchPattern]","[%Modifiers]");
regexResult = thisString.search(thisRegexObject);
nbSetVar("[RegexResult]", regexResult);



2) Attach this script to the click event of a Button ...
Code: Select all
SetVar "[StringToBeSearched]" "Toronto is the center of the Universe"
SetVar "[SearchPattern]" "CENTER"
SetVar "[Modifiers]" "i"

Call "gkRegex" "[StringToBeSearched]" "[SearchPattern]" "[Modifiers]" "[RegexResult]"
AlertBox "RegexResult" "[RegexResult]"


3) Run the publication and click on the Button ... you should get an AlertBox with the result of 15 (i.e. the position of c (of the word center) within the string "Toronto is the center of the Universe".

For details about Modifiers and Search Patterns, check out this page ... http://www.w3schools.com/jsref/jsref_obj_regexp.asp

You will need to take care in passing characters like [ and ] ... that have special meaning within NeoBook commands (use [#91] and [#93] instead) ... and if you use the \ character, be sure to use the ! to ensure that NeoBook does not attempt to do a division on the contents..
User avatar
Gaev
 
Posts: 3728
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Re: Next NeoBook Update Needs Regex

Postby TMcD » Sat May 23, 2015 11:34 pm

Well your sample does work, but replacing search pattern with this:

Code: Select all
^([0]?[1-9]|[1|2][0-9]|[3][0|1])[.\/-]([0]?[1-9]|[1][0-2])[.\/-]([0-9]{4}|[0-9]{2})$


To find: 1/12/2015

Doesn't work.

* Yes, I changed:
Code: Select all
SetVar "[StringToBeSearched]" "1/12/2015 the center of the Universe"
TMcD
 
Posts: 237
Joined: Sun Apr 10, 2005 11:20 am

Re: Next NeoBook Update Needs Regex

Postby TMcD » Sat May 23, 2015 11:39 pm

Like I said, should be native, as in:

StringToSearch (as in: SetVar "[StringToBeSearch]" "1/12/2015 the center of the Universe")

RegEx: ^([0]?[1-9]|[1|2][0-9]|[3][0|1])[.\/-]([0]?[1-9]|[1][0-2])[.\/-]([0-9]{4}|[0-9]{2})$

RegExResult: (in this case) 0
TMcD
 
Posts: 237
Joined: Sun Apr 10, 2005 11:20 am

Re: Next NeoBook Update Needs Regex

Postby Gaev » Sun May 24, 2015 8:45 am

TMcD:

1) I tried using your Regex Pattern directly inside the (javascript) Function ... it did NOT work ... after much experimentation, I found that this string works ...
Code: Select all
([0]?[1-9]|[1|2][0-9]|[3][0|1])[.\/-]([0]?[1-9]|[1][0-2])[.\/-]([0-9]{4}|[0-9]{2})
... i.e. without the ^ and $ character wrappers ... please try it and let me know ... I would do it myself, except that I do not have the time to replace all the special characters with their [#xx] equivalents ... as mentioned before, you can not use this string AS IS inside a SetVar command ... the special characters conflict with what NeoBook uses as "parsing commands".

2) If it does not work, please copy/post the contents of your SetVar command here.

3) If you do not want to fart around with the [#xx] equivalents, you could hard-code this string inside the (javascript) function ... and either make this another (less generic) Function e.g. ...

Call "gkRegexDate" "[StringToBeSearched]" "[RegexResult]"

... or pass a DESIGNATED EQUATE in the "SearchPattern" parameter e.g. ...

Call "gkRegex" "[StringToBeSearched]" "@@@SearchForDateAmericanFormat@@@" "[Modifiers]" "[RegexResult]"

... and have the generic function do an if/then/else based on this value.
User avatar
Gaev
 
Posts: 3728
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada


Return to NeoBook Suggestions

Who is online

Users browsing this forum: No registered users and 0 guests

cron