How to write a parser in C?

Regular Expressions (computing): How difficult would it be for Facebook to write a parser that can tell the difference between closing parentheses and the ')'s that occur as part of an emoticon?

  • Answer:

    I expect that facebook (or anyone else who might care to parse emoticons would write something like this: (\s[:;8X][-']{0,1}[\)\(psD]\s) In english it says this: Look for a two or three character pattern where the first character (the eyes) is either a colon, a number 8, or a capital X, and the last character (the mouth) is a left/right parenthesis, lowercase p, uppercase D, or a lowercase s. Optionally, a single dash, or apostrophe character could be used for the nose, or a tear in the second character of the pattern. Example of the pattern matching on rubular: http://rubular.com/r/NFlNqDlchn This is quite simple - you could start factoring in the non-smilie types of emoticons like (Y), which is commonly a 'thumbs up', or you could tackle those funny reverse smilies everyone is doing these days. (: I suppose that you'd likely want to include in your code (if you are parsing it on the fly) not to try and insert the emoticon if someone has erased the image and typed the same string of text again. If you're trying to figure out how to add a smilie to the end of your paren, for example. As always, there's a relevant xkcd:

Cameron Hurd at Quora Visit the source

Was this solution helpful to you?

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.