Questions tagged [string-parsing]

The action of retrieving data from a string

String parsing is the action of extracting or modifying data pieces from a string. For example, one might parse a string to remove all quotation marks or to find all items inside quotation marks.

970 questions
10
votes
9 answers

c#. Parse and find some word in string

I have some string bla bla bla bla What is the best and fastest way to get text inside <>?
Ievgen
  • 4,261
  • 7
  • 75
  • 124
10
votes
3 answers

Why can I not reverse the result of str::split?

According to the docs for Split, there is a rev method on the result of doing split on a string: fn main() { let mut length = 0; let mut mult = 1; for part in "1:30".split(":").rev() { length += mult *…
Bilal Syed Hussain
  • 8,664
  • 11
  • 38
  • 44
10
votes
8 answers

How to get the name of the parent folder of a file specified by its full path?

In Matlab, I have a string containing a path to a file: path = 'C:/Data/Matlab/Dir/file.m' I want now want to extract the 'Dir' part of the string. One way to do this is: [first, second, third, fourth, fifth] = strtok(path, '/') And then take the…
Karnivaurus
  • 22,823
  • 57
  • 147
  • 247
10
votes
2 answers

How to display returned JSON from a jQuery .ajax post

I am starting work on a project that is built completely on JSON data. It is returned like this: {"location":{"id":10,"contactPhone":"8675309","contactName":"bob","name":"bill smith","zipCode":"90210","state":"California","address1":"104 S.…
Dirty Bird Design
  • 5,333
  • 13
  • 64
  • 121
9
votes
3 answers

Are there character collections for all international full stop punctuations?

I am trying to parse utf-8 strings into "bite sized" segments. For example, I would like to break down a text into "sentences". Is there a comprehensive collection of characters (or regex) that correspond to end of sentences in all languages? I'm…
JDelage
  • 13,036
  • 23
  • 78
  • 112
9
votes
4 answers

Javascript math parser library

Is there a good math parser in Javascript? I want to be able to parse something like: LOG(3.14)+5^2+POW(2,LN(X*2,Y)) Thanks,
Mark K
  • 1,224
  • 3
  • 20
  • 30
9
votes
1 answer

troubles with compiling a c++ file including exprTk

I have some troubles compiling a c++ code including exprtk. I want to compile an given example of the package (I called it parser.cpp): #include #include #include "exprtk.hpp" template void trig_function() { …
Daniel
  • 278
  • 3
  • 13
9
votes
3 answers

DateTime.ParseExact - how to parse single- and double-digit hours with same format string?

I want to be able to parse strings of time (hours, minutes, seconds) where the hours run from 0 to 23, and where the preceding zero for one-digit hours is optional. Examples of time strings that I want to be able to parse into valid DateTime…
Anders Gustafsson
  • 15,837
  • 8
  • 56
  • 114
9
votes
1 answer

How safe is SymPy's sympify().evalf()?

We know Python's eval() is evil http://nedbatchelder.com/blog/201206/eval_really_is_dangerous.html and threads throughout StackOverflow suggest to use SymPy's evalf(). As a Python newbie, I can't really convince myself that evalf() is safe as I lack…
arney
  • 795
  • 7
  • 20
8
votes
3 answers

How can I extract an integer from within a string?

I'm working on an assignment and as part of it I need to extract the integer from a string. I've tried using the atoi() function, but it always returns a 0, so then I switched up to strtol(), but it still returns a 0. The goal is to extract the…
Ramux05
  • 332
  • 1
  • 10
8
votes
4 answers

How to use `strtoul` to parse string where zero may be valid?

According to the documentation for strtoul, regarding its return value... This function returns the converted integral number as a long int value. If no valid conversion could be performed, a zero value is returned. What if I'm parsing a…
Jim Fell
  • 13,750
  • 36
  • 127
  • 202
8
votes
3 answers

Good practices for parsing user inputs with special characters?

Greetings, I am the program writer for the rebellion against the evil galactic empire. Right now, we are preparing for a daring assault on the Death Star. I have created a vast database of information about our pilots, droids, and systems aboard…
Vivian River
  • 31,198
  • 62
  • 198
  • 313
8
votes
3 answers

ParseException: Unparseable date: "Wed Mar 30 00:00:00 GMT+05:30 2016" (at offset 4)

Im trying parse a String with a date to convert it into a Date format. Strings are in the following format. Wed Mar 30 00:00:00 GMT+05:30 2016 But when im parsing the String i get a error saying, java.text.ParseException: Unparseable date: "Wed Mar…
Ryan Aluvihare
  • 225
  • 1
  • 2
  • 9
8
votes
1 answer

Can I use python 're' to parse complex human names?

So one of my major pain points is name comprehension and piecing together household names & titles. I have a 80% solution with a pretty massive regex I put together this morning that I probably shouldn't be proud of (but am anyway in a kind of sick…
mzniko
  • 83
  • 5
8
votes
7 answers

How do you get an unsigned long out of a string?

What's the safest and best way to retrieve an unsigned long from a string in C++? I know of a number of possible methods. First, converting a signed long taken from atol. char *myStr; // Initalized to some value somehow. unsigned long n =…
Daniel Bingham
  • 12,414
  • 18
  • 67
  • 93
1 2
3
64 65