title: I want to split a string using sscanf in c++. My String will be either "a.b" or "a:b"or "ab" format
body: <pre><code>main()
  {
      char *tokenstring = "a.b"; 
      char o[10],s[10];
      sscanf(tokenstring, "%[^'.'].%s", o, s);
      printf("%s\n%s\n ", o, s);
  }
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>a
  b
  </code></pre>
  
  <p>This is fine. But My input string format varies.  </p>
  
  <pre><code>string tokenstring = a.b;
  </code></pre>
  
  <p>I am looking for sscaf logic which works for both inputs. a.b or a:b or ab</p>
  
  <p>one more condition. I have chances that my string may not contain either of the delimiters, which means a single value. In that case I want that single value in to some variable. eg: char *tokenstring = "ab"; </p>
  
  <p>something similar to <code>result = sscanf(tokenstring, "%[^':']: or [^'.']. %s", o, s);</code></p>