Looking for a string policy search API

Started by
4 comments, last by Anthony Serrano 10 years, 5 months ago

I'm looking for an API that would allow you to search strings for certain policies. For example, I would want to return strings that have a number pattern of a social security number, xxx-xx-xxxx, or maybe just a keyword(s) search. It would be nice to combine multiple policy searches into one search. Does an API like this exist out there free or paid? Preferably in C#? And if not, could you recommend where I should start looking to implement something like this myself?

Thanks!

Advertisement

The most flexible way to do this would probably be a regular expression (aka regex) and yes, there is a regex library for c#. In fact it's part of the .net framework

Annoyingly, the .net version uses a slightly different syntax to the old style regexs, which means you will have to understand and tweak many common existing regexs. You will easily find regexs for common patterns like social security numbers, etc

if you think programming is like sex, you probably haven't done much of either.-------------- - capn_midnight

The most flexible way to do this would probably be a regular expression (aka regex) and yes, there is a regex library for c#. In fact it's part of the .net framework

Annoyingly, the .net version uses a slightly different syntax to the old style regexs, which means you will have to understand and tweak many common existing regexs. You will easily find regexs for common patterns like social security numbers, etc

That's what I figured I'd have to use. I was put off from them because I had to use one in another project I worked on and I had no idea exactly how it worked. I guess I'll have to take the time to learn about them. Thanks!

That's what I figured I'd have to use. I was put off from them because I had to use one in another project I worked on and I had no idea exactly how it worked. I guess I'll have to take the time to learn about them. Thanks!


TBF, they can be a pain in the ass. There's a saying about people who, when confronted with a problem, think
“I know, I'll use regular expressions.” Now they have two problems. :D

But they are an incredibly useful tool for the kind of work you're describing.

if you think programming is like sex, you probably haven't done much of either.-------------- - capn_midnight

Yeah, my order of operations would be grep/sscanf/regex in that order. sscanf probably not very useful if you didn't write the data yourself.

"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley

That's what I figured I'd have to use. I was put off from them because I had to use one in another project I worked on and I had no idea exactly how it worked. I guess I'll have to take the time to learn about them. Thanks!


TBF, they can be a pain in the ass. There's a saying about people who, when confronted with a problem, think
“I know, I'll use regular expressions.” Now they have two problems. biggrin.png

But they are an incredibly useful tool for the kind of work you're describing.


Yup. Regular expressions are powerful and important to understand, but it's just as important to understand when NOT to use them.

Too many people see them as a cure-all solution for parsing-related problems, completely ignorant to the fact that regular expressions and the grammars they define are the simplest form of grammar (functionally equivalent to finite state machines), and thus there are many problems for which they are only a partial solution at best (such as parsing natural languages).

For example, they're great for extracting social security numbers or phone numbers from text, and decent (if extremely complex) at validating e-mail addresses, but totally incapable of validating C code.

This topic is closed to new replies.

Advertisement