Advertisement
asan13

Untitled

Jul 26th, 2017
1,239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
D 0.50 KB | None | 0 0
  1. string findGUID(in string s)
  2. {
  3.     string guid;
  4.     if (auto ss = s.find(`<div id=`)) {
  5.         if (ss.length < 9)
  6.             return null;
  7.  
  8.         ss = ss[9..$];
  9.  
  10.         auto end = ss.indexOfAny(`'"`);
  11.         if (end >= 0)
  12.             guid = ss[0..end];
  13.     }
  14.  
  15.     return guid;
  16. }
  17.  
  18. unittest {
  19.     assert(!findGUID(null));
  20.     assert(!findGUID("asdasfasw"));
  21.     assert("9527d19b" == findGUID(`<div id="9527d19b">#Text`));
  22.     assert("9527d19b" == findGUID(`<div id='9527d19b'>#Text`));
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement