problem about string-parsing-Collection of common programming errors
MengQi Han
javascript regex string-parsing
i am new to regex. I am trying to parse all contents inside curly brackets in a string. I looked up this post as a reference and did exactly as one of the answers suggest, however the result is unexpected.Here is what i didvar abc = “test/abcd{string1}test{string2}test” //any string var regex = /{(.+?)}/ regex.exec(abc) // i got [“{string1}”, “string1”]//where i am expecting [“string1”, “string2”]i think i am missing something, what am i doing wrong?updatei was able to get it with /g for a globa
the Tin Man
ruby string string-parsing
I have a string, say ‘123’, and I want to convert it to 123.I know you can simply do some_string.to_i, but that converts ‘lolipops’ to 0, which is not the effect I have in mind. I want it to blow up in my face when I try to convert something invalid, with a nice and painful Exception. Otherwise, I can’t distinguish between a valid 0 and something that just isn’t a number at all.EDIT: I was looking for the standard way of doing it, without regex trickery.
Bart Kiers
c# string parsing function string-parsing
I need to know if there is any library out there that will allow me to, given a certain string representing a mathematical function, say, x^2+x+1, (don’t care about how the string format, any will work for me) generates a C# func that will represent said function.
Danny Varod
c# parameters string-parsing
I Have a string array with 5 values, i want the program to loop even though i don’t enter a value for the arrays. If I split the arrays without inserting anything (pressing ….. (5 times “.” to split the array) then it doesn’t crash it will just loop. But if i just hit enter, then the program crashes.Is there a way to fix the loop so that even though there is no kind of input, that it won’t crash? (It also crashes if you don’t complete all 5 values.)Net = Console.ReadLine();string[] oktet = new
Scott Biggs
android string nullpointerexception long-integer string-parsing
I’ve spent the past two hours debugging what seems extremely unlikely. I’ve stripped the method of a secondary Android Activity to exactly this:public void onClick(View v) {String str = “25”;long my_long = Long.getLong(str); } // onClick (v)And yeah, I get a crash with the good ol’ NullPointerException:09-11 02:02:50.444: ERROR/AndroidRuntime(1588): Uncaught handler: thread main exiting due to uncaught exception 09-11 02:02:50.464: ERROR/AndroidRuntime(1588): java.lang.NullPointerExceptionIt lo
Jake King
c string-parsing sscanf
I’m parsing a string (a char*) and I’m using sscanf to parse numbers from the string into doubles, like so:// char* expression; double value = 0; sscanf(expression, “%lf”, &value);This works great, but I would then like to continue parsing the string through conventional means. I need to know how many characters have been parsed by sscanf so that I may resume my manual parsing from the new offset.Obviously, the easiest way would be to somehow calculate the number of characters that sscanf pa
relower
javascript jquery regex string-parsing
I want to parse Dailymotion video url to get video id in javascript, like below:http://www.dailymotion.com/video/x44lvdvideo id: “x44lvd”i think i need regex string to get a video id for all dailymotion video url combinations.i found url parser regex for YouTube links, its working well like below:var regExp = /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/;var match = url.match(regExp);var videoID = “”;if (match && match[7].length == 11){videoID = match[
Ocelot20
c# .net type-conversion string-parsing
Obviously this isn’t something you would want to do unless you’re in a helpless situation, but does anyone have a good example of something like this (bonus points for thinking of a clearer method name):public static object ConvertToBestGuessPrimitive(string toConvert) {if(looksLikeAnInt){return as an int;}else if(looksLikeABoolean){return as a boolean;}else{return as a string;} }The only idea I had was to chain together a bunch of TryParse methods together in a sensible order and fall back to s
Web site is in building