ed08724 6 Posted December 14, 2016 Report Share Posted December 14, 2016 (edited) Can someone please help me getting the following regex to work. the regex works fine in the regex editor but not in the code.I tried using \\ in place of every \ and that got rid of the errors but it didn't find any results. set(#isbnfile," 0078025877 978-0078025877","Global") clear list(%isbns) add list to list(%isbns,$find regular expression(#isbnfile,"(?:ISBN(?:-1[03])?:? )?((?<=[^\\d])|(?<=^))(?=[0-9X]{10}([^\\d]|\\Z)|(?=(?:[0-9]+[- ]){3})[- 0-9X]{13}([^\\d]|\\Z)|97[89][0-9]{10}([^\\d]|\\Z)|(?=(?:[0-9]+[- ]){4})[- 0-9]{17}([^\\d]|\\Z))(?:97[89][- ]?)?[0-9]{1,5}[- ]?[0-9]+[- ]?[0-9]+[- ]?[0-9X]([^\\d]|\\Z)"),"Delete","Global") Thanks,Ed Newman Edited December 14, 2016 by ed08724 Quote Link to post Share on other sites
Code Docta (Nick C.) 638 Posted December 14, 2016 Report Share Posted December 14, 2016 which editor?You need to make sure it is .NET flavor of regex. I use http://regexhero.net/tester/to test my regex and never had an issue in ubot. Also which ubot version?I did experience some issues with the latest version .43 with unpronounceable results. CD Quote Link to post Share on other sites
ed08724 6 Posted December 14, 2016 Author Report Share Posted December 14, 2016 (edited) ubot 5 and I mean the regex editor that can test regex on the view menu in ubot. the regex is fine it just needs to be escaped properly to be put in a string. Edited December 15, 2016 by ed08724 Quote Link to post Share on other sites
Code Docta (Nick C.) 638 Posted December 15, 2016 Report Share Posted December 15, 2016 In my experience regex hasn't been that long. It would help to see the text or an example of the text you are parsing. Sometimes it is better to do it in more than one step. Break down the HTML or maybe even better use XPATh. Our answer is only as good as the info you provide. More info in, more info returned. Quote Link to post Share on other sites
ed08724 6 Posted December 15, 2016 Author Report Share Posted December 15, 2016 (edited) a simple example is in the first line of the example code.set(#isbnfile," 0078025877 978-0078025877","Global")you can see if you put both in the editor it works fine. I think ubot is not interpreting the characters correctly when put into a string Edited December 15, 2016 by ed08724 Quote Link to post Share on other sites
ed08724 6 Posted December 15, 2016 Author Report Share Posted December 15, 2016 i was able to get it to work by putting the regex in a file and then loading the file into a variable then running the find on a variable instead of a constant.not the ideal answer but it will do.add list to list(%isbns,$find regular expression(#isbnfile,#regex),"Delete","Global") Quote Link to post Share on other sites
Code Docta (Nick C.) 638 Posted December 15, 2016 Report Share Posted December 15, 2016 Awesome!Did you report this in the bug tracker? please give them the example and they will fix it, if you don't they wont CD Quote Link to post Share on other sites
ed08724 6 Posted December 15, 2016 Author Report Share Posted December 15, 2016 I doubt this is a bug its just a matter of properly escaping the string just like if you need a " in a string you need to put \" there are probably other characters that have to be escaped as well. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.