[Question]
  [
Given a string input, write a program that prints a [truthy value](http://meta.codegolf.stackexchange.com/q/2190/20634) to STDOUT or equivalent if the input is a valid UUID, without using regexes.
A valid UUID is 
> 
> 32 hexadecimal digits, displayed in five groups separated by hyphens, in the form 8-4-4-4-12 for a total of 36 characters (32 alphanumeric characters and four hyphens).
> 
> 
> [**Source**](https://en.wikipedia.org/wiki/Universally_unique_identifier#Definition)
> 
> 
> 
## Test Cases
```
0FCE98AC-1326-4C79-8EBC-94908DA8B034
    => true
00000000-0000-0000-0000-000000000000
    => true
0fce98ac-1326-4c79-8ebc-94908da8b034
    => true
0FCE98ac-1326-4c79-8EBC-94908da8B034
    => true
{0FCE98AC-1326-4C79-8EBC-94908DA8B034}
    => false (the input is wrapped in brackets)
0GCE98AC-1326-4C79-8EBC-94908DA8B034
    => false (there is a G in the input)
0FCE98AC 1326-4C79-8EBC-94908DA8B034
    => false (there is a space in the input)
0FCE98AC-13264C79-8EBC-94908DA8B034
    => false (the input is missing a hyphen)
0FCE98AC-13264-C79-8EBC-94908DA8B034
    => false (the input has a hyphen in the wrong place)
0FCE98ACD-1326-4C79-8EBC-94908DA8B034
    => false (one of the groups is too long)
0FCE98AC-1326-4C79-8EBC-94908DA8B034-
    => false (has a trailing hyphen)
0FCE98AC-1326-4C79-8EBC-94908DA8B034-123
    => false (too many groups)
0FCE98AC13264C798EBC94908DA8B034
    => false (there is no grouping)
```
## Rules
* Regular Expressions are not allowed
* Literal pattern matching which is *like* a regex is not allowed. For example, using `[0-9a-fA-F]` or other hexadecimal identifiers (we'll call this `n`) and then matching `nnnnnnnn-nnnn-nnnn-nnnn-nnnnnnnnnnnn` or `n[8]-n[4]-n[4]-n[4]-n[12]` is not allowed
* The input may either be taken from `STDIN` or as an argument to a function
* The input is case insensitive
* It is safe to assume that the input will *not* contain linefeeds or newlines.
* The input may contain any printable ASCII characters (spaces included)
* A [truthy value](http://meta.codegolf.stackexchange.com/q/2190/20634) must be printed to `STDOUT` or equivalent if the input is a valid uuid
* A [falsey value](http://meta.codegolf.stackexchange.com/q/2190/20634) must be printed to `STDOUT` or equivalent if the input is *not* a valid uuid
* If using a function, instead of using `STDOUT`, the output can be the return value of the function
* The truthy/falsey value cannot be printed to `STDERR`.
* [Standard loopholes](http://meta.codegolf.stackexchange.com/q/1061/20634) apply
* This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so the shortest program in bytes wins. Good luck!
## Leaderboard
This is a Stack Snippet that generates both a leaderboard and an overview of winners by language.
To ensure your answer shows up, please start your answer with a headline using the following Markdown template
```
## Language Name, N bytes
```
Where N is the size, in bytes, of your submission
If you want to include multiple numbers in your header (for example, striking through old scores, or including flags in the byte count), just make sure that the actual score is the *last* number in your header
```
## Language Name, <s>K</s> X + 2 = N bytes
```
```
var QUESTION_ID=66496;var OVERRIDE_USER=20634;function answersUrl(e){return"//api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"//api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="<h1>"+e.body.replace(OVERRIDE_REG,"")+"</h1>")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/<a/.test(o)&&(o=jQuery(o).text()),s[o]=s[o]||{lang:e.language,user:e.user,size:e.size,link:e.link}});var t=[];for(var o in s)s.hasOwnProperty(o)&&t.push(s[o]);t.sort(function(e,s){return e.lang>s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(-?\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;
```
```
body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}
```
```
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"> <div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr></thead> <tbody id="answers"> </tbody> </table> </div><div id="language-list"> <h2>Winners by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr></thead> <tbody id="languages"> </tbody> </table> </div><table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table>
```
  
[Answer]
# JavaScript ES6, ~~73~~ ~~55~~ 56 chars
```
s=>s.split`-`.map(x=>x.length+`0x${x}0`*0)=="8,4,4,4,12"
```
The previous 55 chars version has a problem with trailing spaces in group:
```
s=>s.split`-`.map(x=>x.length+("0x"+x)*0)=="8,4,4,4,12"
// "00000000-0000-0000-000 -000000000000" true
```
Test:
```
f=s=>s.split`-`.map(x=>x.length+`0x${x}0`*0)=="8,4,4,4,12"
;`0FCE98AC-1326-4C79-8EBC-94908DA8B034
0fce98ac-1326-4c79-8ebc-94908da8b034
0FCE98ac-1326-4c79-8EBC-94908da8B034
0GCE98AC-1326-4C79-8EBC-94908DA8B034
0FCE98AC-13264C79-8EBC-94908DA8B034
0FCE98AC-13264-C79-8EBC-94908DA8B034
0FCE98ACD-1326-4C79-8EBC-94908DA8B034
0FCE98AC-1326-4C79-8EBC-94908DA8B034-123
00000000-0000-0000-0000-000000000000
D293DBB2-0801-4E60-9141-78EAB0E298FF
0FCE98AC-1326-4C79-8EBC-94908DA8B034-
00000000-0000-0000-000 -000000000000`.split(/\n/g).every(s=>f(s)==/^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i.test(s))
```
[Answer]
## CJam, ~~31~~ ~~30~~ 29 bytes
```
8 4__C]Nf*'-*qA,s'G,_el^+Ner=
```
[Run all test cases here.](http://cjam.aditsu.net/#code=qN%2F%7B%3AQ%3B%0A%0A8%204__C%5DNf*'-*QeuA%2Cs'G%2C65%3E%2BNer%3D%0A%0A%5DoNo%7D%2F&input=D293DBB2-0801-4E60-9141-78EAB0E298FF%0A0FCE98AC-1326-4C79-8EBC-94908DA8B034%0A0fce98ac-1326-4c79-8ebc-94908da8b034%0A0FCE98ac-1326-4c79-8EBC-94908da8B034%0A0GCE98AC-1326-4C79-8EBC-94908DA8B034%0A0FCE98AC-13264C79-8EBC-94908DA8B034%0A0FCE98AC-13264-C79-8EBC-94908DA8B034%0A0FCE98ACD-1326-4C79-8EBC-94908DA8B034%0A0FCE98AC-1326-4C79-8EBC-94908DA8B034-%0A0FCE98AC-1326-4C79-8EBC-94908DA8B034-123)
### Explanation
Instead of pattern matching the input directly, we're first transforming it to a simpler form which can be easily compared against a single pattern string.
```
8 4__C] e# Push the array of segment lengths, [8 4 4 4 12].
Nf*     e# Turn that into strings of linefeeds of the given length.
'-*     e# Join them by hyphens, giving "NNNNNNNN-NNNN-NNNN-NNNN-NNNNNNNNNNNN".
q       e# Read the input.
A,s     e# Push the string "0123456789".
'G,_el^ e# Push the string "ABCDEFabcdef".
+       e# Concatenate the two strings.
N       e# Push a linefeed.
er      e# Replace all hexadecimal digits with linefeeds.
=       e# Check for equality with the pattern string.
```
[Answer]
## PowerShell, ~~29~~ ~~21~~ ~~84~~ ~~49~~ 37 Bytes
```
param($g)@{36=$g-as[guid]}[$g.length]
```
Many thanks to the folks in the comments assisting with this golfing to keep up with the changing rules -- [TessellatingHeckler](https://codegolf.stackexchange.com/users/571/tessellatingheckler), [iFreilicht](https://codegolf.stackexchange.com/users/19263/ifreilicht), [Jacob Krall](https://codegolf.stackexchange.com/users/4528/jacob-krall), and [Joey](https://codegolf.stackexchange.com/users/15/joey). Please see the edit history for revisions and older versions.
This revision takes input as `$g`, then creates a new hash table `@{}` with one element, index `36` is set equal to `$g-as[guid]`. This uses the built-in [`-as` operator](https://technet.microsoft.com/en-us/library/hh847763.aspx) to attempt conversion between two .NET data types -- from `[string]` to `[guid]`. If the conversion is successful, a `[guid]` object is returned, else `$null` is returned. This portion ensures that the input string is a valid .NET GUID.
The next step is to index into the hash table with `[$g.length]`. If `$g` is not exactly 36 characters in length, the hash table will return `$null`, which will be output as a falsey value. If `$g` is 36 characters in length, then the result of the .NET call will be output. If `$g` is not a valid .NET GUID (in any form), then it will output `$null` as a falsey value. Otherwise it will output a .NET GUID object as a truthy value - the only way that can be output is if it matches the requested format of the challenge.
### Examples
Here I am encapsulating the script call in parens and explicitly casting as a Boolean for clarity.
```
PS C:\Tools\Scripts\golfing> [bool](.\check-if-a-uuid-is-valid.ps1 '0FCE98AC-1326-4C79-8EBC-94908DA8B034')
True
PS C:\Tools\Scripts\golfing> [bool](.\check-if-a-uuid-is-valid.ps1 '0FCE98AC-1326-4C79-8EBC-94908DA8B034D')
False
PS C:\Tools\Scripts\golfing> [bool](.\check-if-a-uuid-is-valid.ps1 '0FCE98AC13264C798EBC94908DA8B034')
False
```
[Answer]
## Emacs Lisp, 236 Bytes
```
(lambda(s)(and(eq(string-bytes s)36)(let((l(string-to-list s))(i 0)(h '(8 13 18 23))(v t))(dolist(c l v)(set'v(and v(if(member i h)(and v(eq c 45))(or(and(> c 47)(< c 58))(and(> c 64)(< c 91))(and(> c 96)(< c 123))))))(set'i(+ i 1))))))
```
Ungolfed:
```
(lambda (s)
  (and (eq (string-bytes s) 36) ; check length
       (let ((l (string-to-list s))
             (i 0)
             ; location of hyphens
             (h '(8 13 18 23))
             (v t))
         (dolist (c l v)
           (set 'v (and v (if (member i h)      ; check if at hyphen position
                              (and v (eq c 45)) ; check if hyphen
                            (or (and (> c 47) (< c 58))      ; check if number
                                (and (> c 64) (< c 91))      ; check if upper case letter
                                (and (> c 96) (< c 123)))))) ; check if lower case letter
           (set 'i (+ i 1)))))) ; increment
```
[Answer]
Due to [changes to the rules](https://codegolf.stackexchange.com/revisions/66496/18), this answer is no longer competitive :(
# C, 98
```
main(a,n){printf("%d",scanf("%8x-%4hx-%4hx-%4hx-%4hx%8x%n%c",&a,&a,&a,&a,&a,&a,&n,&a)==6&&n==36);}
```
Mostly fairly self explanatory. The `%n` format specifier gives the number of bytes read so far, which should be 36. `scanf()` returns the number of matched items, which should be 6. The final `%c` should not match anything. If it does, then there is trailing text, and `scanf()` will return 7.
Compile with `-w` to suppress the pesky warnings (there are several).
[Answer]
# JavaScript ES6, 70 ~~83~~
**NOTE** thx to @Qwertiy for finding a bug (and suggesting some improvements and fixes)
Thx @C·¥è…¥·¥è ÄO'B Ä…™·¥á…¥ 2 bytes saved
Other 9 bytes saved simplifiying the length check (the complex way *was* shorter in the first draft, but not now)
```
u=>u.split`-`.every((h,l,u)=>u[4]&&-`0x${h}1`&&h.length-'40008'[l]==4)
```
**Explained**
```
u=>u.split`-` // make an array splitting at '-'
.every( // for every element the following must be true
 (h,l,u)=> // h is the element, l is the index, u is the whole array
 u[4] // element 4 must be present (at least 5 element in array)
 && -`0x${h}1` // element must be a valid hex string with no extraneous blanks (else NaN that is falsy)
 // get requested length from index (8,4,4,4,12 sub 4 to put in 1 char)
 // a 6th elements will be rejected as undefined != 4
 && h.length-'40008'[l]==4// then check element length
)
```
Test snippet
```
f=u=>u.split`-`.every((h,l,u)=>u[4]&&-`0x${h}1`&&h.length-'40008'[l]==4)
console.log=x=>O.innerHTML+=x+'\n'
;[
  ['0FCE98AC-1326-4C79-8EBC-94908DA8B034',true],
  ['0fce98ac-1326-4c79-8ebc-94908da8b034',true],
  ['0FCE98ac-1326-4c79-8EBC-94908da8B034',true],
  ['00000000-0000-0000-0000-000000000000', true],
  ['ffffffff-ffff-ffff-ffff-ffffffffffff', true],
  ['0GCE98AC-1326-4C79-8EBC-94908DA8B034',false],
  ['0FCE98AC-13264C79-8EBC-94908DA8B034',false],
  ['0FCE98AC-13264-C79-8EBC-94908DA8B034',false],
  ['0FCE98ACD-1326-4C79-8EBC-94908DA8B034',false],
  ['0FCE98AC-1326-4C79-8EBC',false],
  ['0FCE98AC-1326-4C79-8EBC-94908DA8B034-',false],
  ['00000000-0000-0000-000 -000000000000', false],
  ['0FCE98AC-1326-4C79-8EBC-94908DA8B034-123',false],
].forEach(x=>{
  var t=x[0], r=f(t), k=x[1]
  console.log('Test '+t+' result '+r+(r==k?' ok':' fail'))
})
```
```
<pre id=O></pre>
```
[Answer]
Due to [changes to the rules](https://codegolf.stackexchange.com/revisions/66496/18), this answer is no longer competitive :(
# Pure Bash (no external utilities), 78
```
printf -vv %8s-%4s-%4s-%4s-%12s
p=${v// /[[:xdigit:]]}
[ "$1" -a ! "${1/$p}" ]
```
Takes input from the command line.
* The `printf` builds the following string `- - - -`.
* The `p=` line transforms this to the following pattern: `[[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]]-[[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]]-[[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]]-[[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]]-[[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]]`. Note this looks an awful lot like a regular expression. However, it is not in this context. It is a pattern for [shell pattern matching](https://www.gnu.org/software/bash/manual/html_node/Pattern-Matching.html). This is similar *in concept* to a regular expression, but is a different construct (and syntax).
* The last line checks if
	+ the input is non-empty
	+ if pulling the pattern out of the input string produces an empty string
Idiomatic to shell, a return code of 0 indicates success/TRUE and 1 indicates failure/FALSE. The return code may be inspected with `echo $?` after running the script.
[Answer]
# Jolf, 32 bytes
Try it [here!](http://conorobrien-foxx.github.io/Jolf/#code=IGVHaSctRE4mYkgqMjg9bEguWzgsNCw0LDQsMTJdU30)
```
 eGi'-DN&bH*28=lH.[8,4,4,4,12]S}
 e                               Property "e"very of next object
  Gi'-                           Split i at hyphen
      DN                       } every comparison function
        &                        logical conjugation of next two arguments
         bH*28                   base 16 of H (first arg); is NaN (falsey) if invalid
              =                  equality of next two items
               lH                the length of H (first arg)
                 .            S  the Sth (index) member of the object inbetween
                  [8,4,4,4,12]   array of lengths
```
Because of an error in my code, this is longer than it should be. :( `[8,4,4,4,12]` *should* be the same as `{8444*26}`, but `}` is also the closing of a function :P
[Answer]
# [MATL](http://esolangs.org/wiki/MATL), 55 bytes
```
jttn36=?[9,5,5,5]XsXK)45=?36:Km~)4Y2'A':'F'hm?}F]]]N~1$
```
I refrained from using the `Yb` function (`strsplit`) because it's somewhat similar to `regexp(..., 'split')`. This only uses indexing and character comparisons.
### Example
```
>> matl
 > jttn36=?[9,5,5,5]XsXK)45=?36:Km~)4Y2'A':'F'hm?}F]]]N~1$
 > 
> This is a test
0
>> matl
 > jttn36=?[9,5,5,5]XsXK)45=?36:Km~)4Y2'A':'F'hm?}F]]]N~1$
 > 
> D293DBB2-0801-4E60-9141-78EAB0E298FF
1
```
### Explanation
```
jt                     % input string, duplicate
tn36=?                 % if length is 36
  [9,5,5,5]XsXK        % build and copy indices of required '-' positions
  )45=?                % if those entries are indeed '-'
    36:Km~)            % logical index of remaining positions
    4Y2'A':'F'h        % allowed chars in those positions
    m?                 % if all those entries are legal: do nothing
    }                  % else
      F                % false value
    ]                  % end
  ]                    % end
]                      % end
N~                     % true if stack is empty
1$                     % display last result only
```
[Answer]
## CJam, ~~52~~ 42 bytes
```
qeu__{A7*)<},\'-/83 3b{)4*}%.{\,=}[1]5*=*=
```
[Try it online](http://cjam.aditsu.net/#code=qeu__%7BA7*)%3C%7D%2C%5C%27-%2F83%203b%7B)4*%7D%25.%7B%5C%2C%3D%7D%5B1%5D5*%3D*%3D&input=0FCE98aC-1326-4C79-8EBC-94908DA8B02F). Outputs the original string if true, outputs empty string if false ([this is allowed](http://meta.codegolf.stackexchange.com/a/5062/36670)).
Explanation:
```
qeu__                                      e# Take input, make 2 copies
     {A7*)<},\                             e# Remove invalid characters from first copy
              '-/                          e# Split top of stack on '-
                 83 3b{)4*}%               e# Array of group lengths: [8 4 4 4 12]
                            .{\,=}[1]5*=   e# Compare two arrays, return true if group lengths are correct
                                        *= e# Multiply this value by original string (0 = empty string, 1 = same string)
```
[Answer]
# Julia, 86 bytes
```
s->(t=split(s,"-");map(length,t)==[8,4,4,4,12]&&all(i->!isnull(tryparse(Int,i,16)),t))
```
This is an anonymous function that accepts a string and returns a boolean. To call it, give it a name, e.g. `f=s->...`.
Ungolfed:
```
function f(s::AbstractString)
    # Split the input into an array on dashes
    t = split(s, "-")
    # Ensure the lengths are appropriate
    ok1 = map(length, t) == [8, 4, 4, 4, 12]
    # Ensure each element is a valid hexadecimal number
    ok2 = all(i -> !isnull(tryparse(Int, i, 16)), t)
    return ok1 && ok2
end
```
[Answer]
## C# 196 bytes
```
using System.Linq;class P{bool T(string v){var r=v.Length==36;for(var i=0;i<v.Length;i++)r&=new[]{8,13,18,23}.Any(t=>t==i)?v[i]=='-':v[i]>47&&v[i]<58|v[i]>64&&v[i]<71|v[i]>96&&v[i]<103;return r;}}
```
Ungolfed:
```
using System.Linq;
class P
{
    public bool T(string v)
    {
        var r = v.Length == 36;
        for (var i = 0; i < v.Length; i++)
            r &= new[] { 8, 13, 18, 23 }.Any(t => t == i) 
                ? v[i] == '-' 
                : v[i] > 47 && v[i] < 58 | v[i] > 64 && v[i] < 71 | v[i] > 96 && v[i] < 103;
        return r;
    }
}
```
Method `T` can be invoked with any non-null string and will return `true` for valid GUID's, `false` otherwise. This is a constant-time validation; at the cost of three chars you can early-exit the method (change `i < v.Length` to `i < v.Length && r`).
Will try to get the bytecount down further later.
I've obviously left out the [`Guid.ParseExact`](https://msdn.microsoft.com/en-us/library/system.guid.parseexact(v=vs.110).aspx) way because where's the fun in that? Here it is, without much attempt to golf it down further in **86 bytes**:
```
using System;class P{bool T(string v){Guid x;return Guid.TryParseExact(v,"D",out x);}}
```
Ungolfed:
```
using System;
class P
{
    bool T(string v)
    {
        Guid x;
        return Guid.TryParseExact(v, "D", out x);
    }
}
```
[Answer]
# Python 2, ~~99~~ 112 bytes
```
def f(u):
 try:u=u.split()[0];int(u.replace('-',''),16);print[8,4,4,4,12]==map(len,u.split('-'))
 except:print 0
```
On a valid input, it prints `True`. On an invalid input it prints `False` or `0`, depending on why it was invalid. `False` and `0` are both falsey in Python.
The function has to check 3 things:
* Every non-hyphen character is a digit or is in `ABCDEF`
* There are exactly 4 hyphens
* There are 8 characters before the first hyphen, 12 after the last, and 4 between any other two
Here's a breakdown to show how it checks for them. It's slightly out of date but I'm hungry so I'll update it later.
```
def f(u):
    try:
        int(u.replace('-',''),16) # Remove all hyphens from the string and parse what's
                                  # left as a base 16 number. Don't do anything with this
                                  # number, but throw an exception if it can't be done.
        return[8,4,4,4,12]==map(len,u.split('-')) # Split the string at each hyphen and
                                                  # get the length of each resulting
                                                  # string. If the lengths == [8,4,4,4,12],
                                                  # there are the right number of groups
                                                  # with the right lengths, so the string
                                                  # is valid.
    except:
        return 0 # The only way to get here is if the string (minus hyphens) couldn't be
                 # parsed as a base 16 int, so there are non-digit, non-ABCDEF characters
                 # and the string is invalid.
```
[Answer]
## Python 2, 57 bytes
[Thank goodness for built-in!](https://docs.python.org/2/library/uuid.html) - make sure to enclose strings in quotes.
```
import uuid
try:uuid.UUID(input());print 1
except:print 0
```
[Answer]
## Pyth, 39 bytes
```
&&!+1xzd.xi:zK\-k16ZqxKc+zK1mid36"8dinz
```
Try it [here](http://pyth.herokuapp.com/?code=%26%26%21%2B1xzd.xi%3AzK%5C-k16ZqxKc%2BzK1mid36%228dinz&input=0FCE98ac-1326-4c79-8EBC-94908da8Baa&debug=0).
[Answer]
## [Perl 6](http://perl6.org), ~~¬†83¬†~~¬†67 bytes
```
# 83 bytes
{
  (
    my@a=.uc.split('-')
  ).map(*.comb)‚äÜ('0'..'9','A'..'F')
&&
  @a¬ª.chars~~(8,4,4,4,12)
}
```
```
# 67 bytes
{
  (
    $/=.split('-')
  ).map({:16($_)//|()})==5
&&
  $/¬ª.chars~~(8,4,4,4,12)
}
```
( counts do not include newlines or indents as they are not needed )
usage:
```
# give it a name
my &code = {...}
say map &code, ¬´
  D293DBB2-0801-4E60-9141-78EAB0E298FF
  0FCE98AC-1326-4C79-8EBC-94908DA8B034
  0fce98ac-1326-4c79-8ebc-94908da8b034
  0FCE98ac-1326-4c79-8EBC-94908da8B034
  00000000-1326-4c79-8EBC-94908da8B034
¬ª;
# (True True True True True)
say map &code, ¬´
  0GCE98AC-1326-4C79-8EBC-94908DA8B034
 '0FCE98AC 1326-4C79-8EBC-94908DA8B034'
  0FCE98AC-13264C79-8EBC-94908DA8B034
  0FCE98AC-13264-C79-8EBC-94908DA8B034
  0FCE98ACD-1326-4C79-8EBC-94908DA8B034
  0FCE98AC-1326-4C79-8EBC-94908DA8B034-
  0FCE98AC-1326-4C79-8EBC-94908DA8B034-123
¬ª;
# (False False False False False False False)
```
[Answer]
## Common Lisp - 161
```
(lambda(s &aux(u(remove #\- s)))(and(=(length s)36)(=(length u)32)(every(lambda(p)(char=(char s p)#\-))'(8 13 18 23))(ignore-errors(parse-integer u :radix 16))))
```
The returned value if true is the hash, as a number, which is a useful result to have.
### Ungolfed
```
(defun uuid-p (string &aux (undashed (remove #\- string)))
  (and
   ;; length of input string must be 36
   (= (length string) 36)
   ;; there are exactly 4 dashes
   (= (length undashed) 32)
   ;; We check that we find dashes where expected
   (every (lambda (position)
            (char= (char string position) #\-))
          '(8 13 18 23))
   ;; Finally, we decode the undashed string as a number in base 16,
   ;; but do not throw an exception if this is not possible.
   (ignore-errors
    (parse-integer undashed :radix 16))))
```
[Answer]
## F# 44 characters
```
fun s->System.Guid.TryParseExact(s,"D")|>fst
```
In F#, functions with `out` parameters can be called by omitting the out parameter; its value at return will be combined with the function's true return value into a tuple.
Here, the tuple is piped to the `fst` function, which returns its first member, which in this case is the Boolean return value of TryParseExact, indicating the success or failure of the call.
As a check for the correct format, we return `true` only if the string is 36 characters long.
Before I saw RobIII's C# answer, I had not thought of using TryParseExact, so my answer was to have been three characters longer:
```
fun s->System.Guid.TryParse s|>fst&&s.Length=36
```
[`TryParse(string, Guid)`](https://msdn.microsoft.com/en-us/library/system.guid.tryparse(v=vs.110).aspx) accepts input in the following formats:
```
00000000000000000000000000000000 
00000000-0000-0000-0000-000000000000 
{00000000-0000-0000-0000-000000000000} 
(00000000-0000-0000-0000-000000000000)
{0x00000000,0x0000,0x0000,{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}
```
Of these, only the second is 36 characters long.
[Answer]
## Python 2, ~~93~~ ~~89~~ 85 bytes
```
lambda u:(set(u)<=set("-0123456789abcdefABCDEF"))*map(len,u.split("-"))==[8,4,4,4,12]
```
The `map()` call guarantees that the sections are of the right lengths, and the `all()` tests each character for being either a hyphen or an arbitrary-case hex digit. The generator expression is testing each character by iterating through that entire string, so it's not the most performant method, I'm afraid, but it should satisfy the test cases:
```
>>> f=lambda u:(set(u)<=set("-0123456789abcdefABCDEF"))*map(len,u.split("-"))==[8,4,4,4,12]
>>> testcases = """\
... D293DBB2-0801-4E60-9141-78EAB0E298FF
... 0FCE98AC-1326-4C79-8EBC-94908DA8B034
... 0fce98ac-1326-4c79-8ebc-94908da8b034
... 0FCE98ac-1326-4c79-8EBC-94908da8B034
... 00000000-0000-0000-0000-000000000000""".splitlines()
>>> failcases = """\
... 0GCE98AC-1326-4C79-8EBC-94908DA8B034
... 0FCE98AC 1326-4C79-8EBC-94908DA8B034
... 0FCE98AC-13264C79-8EBC-94908DA8B034
... 0FCE98AC-13264-C79-8EBC-94908DA8B034
... 0FCE98ACD-1326-4C79-8EBC-94908DA8B034
... 0FCE98AC-1326-4C79-8EBC-94908DA8B034-
... 0FCE98AC-1326-4C79-8EBC-94908DA8B034-123
... 00000000-0000-0000-000 -000000000000
... 00000000-0000-0000- 000-000000000000""".splitlines()
>>> all(f(u) for u in testcases)
True
>>> any(f(u) for u in failcases)
False
>>> 
```
[Answer]
## SAS, ~~171~~ ~~144~~ 141
```
data;infile stdin;file stdout;input a$9b$14c$19d$24;e=(a!!b!!c!!d='----')*length(_infile_)=36*(1-missing(put(input(compress(_infile_,,'adk'),$hex32.),$hex32.)));put e;run;
```
Actually uses stdin and stdout - one of the lesser-known features of this particular language. Works for the examples given so far, but possibly not in all cases. Can probably be improved upon.
Better approach - one character at a time:
```
data;infile stdin;file stdout;do i=1 to 37;input@i c$1.@;a+ifn(i in(9,14,19,24),c='-',n(input(c,hex.))-36*(i>36&c^=''));end;b=a=36;put b;run;
```
Golfed another 6 characters off the central expression!
Ungolfed:
```
data;
infile stdin;
file stdout;
do i=1 to 37;
input@i c$1.@;
a+ifn(i in(9,14,19,24),c='-',n(input(c,hex.))-36*(i>36&c^=''));
end;
b=a=36;
put b;
run;
```
This generates quite a few warnings and notes in the log, but it doesn't print them to stdout or stderr, so I think this is fair game.
[Answer]
# C, 391 bytes
```
#include<stdio.h>
#include<string.h>
#include<ctype.h>
#define F printf("0")
#define T printf("1")
#define E return 0
main(){char s[99],*t;int k=1,l,i;scanf("%99[^\n]",s);if(s[strlen(s)-1]=='-'){F;E;}t=strtok(s,"-");while(t!=NULL){for(i=0,l=0;t[i]!=0;i++,l++){if(!isxdigit(t[i])){F;E;}}if((k==1&&l!=8)||((k>1&&k<5)&&l!=4)||(k==5&&l!=12)){F;E;}k++;t=strtok(NULL,"-");}if(k==6){T;E;};F;}
```
[Answer]
# MATLAB, 126 bytes
```
function f(a)
b='-';if length(a)==36&&a(9)==b&&a(13)==b&&a(17)==b&&a(21)==b;a(a==b)=[];if any(isnan(hex2dec(a)));0;end;1;end;0
```
[Answer]
## Python 3, 134 bytes
```
def a(i):
 try:l=[1+int(k,16)and(len(k)==c)for k,c in zip(i.split("-"),[8,4,4,4,12])];return(len(l)==5)&(0 not in l)
 except:return 0
```
int(k,16) tries to cast k to a base-16 int. On a character other than 0-9a-fA-F- it fails, in which case we return 0, which is falsy.
Add 1 to that int and we get a guaranteed truthy value - we've stripped away all hyphens with str.split() so we can't get the value -1 and all non-0 ints are truthy.
[Answer]
# C function, 102
[A rule change disallowed my previous c `scanf()`-based answer](https://codegolf.stackexchange.com/revisions/66496/18), so here's another c answer [using `isxdigit()` which I think should be allowed to compete](https://codegolf.stackexchange.com/questions/66496/check-if-a-uuid-is-valid-without-using-regexes#comment161487_66496):
```
i;f(char *s){for(i=8;i<24;i+=5)s[i]=s[i]-45?1:s[i]+3;for(i=0;isxdigit(s[i]);i++);return i==36&&!s[i];}
```
[Try it online.](https://ideone.com/aQBeD8)
* Check for `-` characters (ASCII 45) at the relevant positions - if so, replace them with `0`s (ASCII 48 (=45+3))
* Walk the string checking each char with [`isxdigit()`](http://pubs.opengroup.org/onlinepubs/009695399/functions/isxdigit.html)
* Return TRUE if string length is 36 and final character is NUL.
[Answer]
## Batch, ~~148~~ 139 + 2 = ~~150~~ 141 bytes
```
@set/pu=
@for %%d in (1 2 3 4 5 6 7 8 9 A B C D E F)do @set u=!u:%%d=0!
@if -!u!==-00000000-0000-0000-0000-000000000000 exit/b0
@exit/b1
```
Added 2 bytes because you need to use the `/v` switch to `CMD.EXE`.
Exits with ERRORLEVEL 0 on success, 1 on failure.
Edit: Saved some bytes mainly because `:=` is case insensitive but there were other tweaks too.
[Answer]
## Java, 345 bytes
```
interface q{static void main(String[]a){int i=-1;char[]b=a[0].toCharArray();java.io.PrintStream u=System.out;if(b.length>36||b.length<36)u.print(1<0);if(b[8]!='-'||b[13]!='-'||b[18]!='-'||b[23]!='-')u.print(1<0);while(++i<b.length){if(i!=8&&i!=13&&i!=18&&i!=23){if(!((b[i]>='0'&&b[i]<='F')||(b[i]>='a'&&b[i]<='f')))u.print(1<0);}}u.print(1>0);}}
```
Input is first command line argument. Output is error code(0 means valid UUID, 1 means not valid)
Ungolfed with comments:
```
interface q {
    static void main(String[] a) {
        int i = -1;                                                             // Index
        char[] b = a[0].toCharArray();                                          // Characters from input
        java.io.PrintStream u = System.out;                                     // STDOUT
        if (b.length > 36||b.length < 36)                                       // If input length is not 36
            u.print(1<0);                                                       // Invalid
        if (b[8]!='-'||b[13]!='-'||b[18]!='-'||b[23]!='-')                      // If hasn't got separators at correct positions
            u.print(1<0);                                                       // Invalid
        while (++i<b.length) {                                                  // Iterate over all characters
            if (i!=8 && i!=13 & i!=18 && i!=23) {                               // If not at separator indexes
                if ( !( (b[i]>='0'&&b[i]<='F') || (b[i]>='a'&&b[i]<='f') ))     // If incorrect hexadecimal number
                    u.print(1<0);                                               // Invalid
            }
        }
        u.print(1>0);                                                           // Valid
    }
}
```
EDIT: Didn't notice the STDOUT part. Oops, fixed now.
[Answer]
# Swift 3, 50 bytes
Pass in a string `s`
```
import Foundation
print(UUID(uuidString:s) != nil)
```
[Answer]
# PHP, 109 Bytes
prints 1 for true and 0 for false
```
for($t=($l=strlen($a=$argn))==36;$i<$l;$i++)$t*=$i>7&$i<24&!($i%5-3)?$a[$i]=="-":ctype_xdigit($a[$i]);echo$t;
```
`$i>7&$i<24&!($i%5-3)` is 5 Bytes shorter then `in_array($i,[8,13,18,23])`
112 Bytes
```
echo array_filter(str_split($argn),function($i){return!ctype_xdigit($i);})==[8=>"-",13=>"-",18=>"-",23=>"-"]?:0;
```
113 Bytes
```
echo array_diff(str_split(strtolower($argn)),array_map(dechex,range(0,15)))==[8=>"-",13=>"-",18=>"-",23=>"-"]?:0;
```
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal/tree/version-2), 167 [bitsv2](https://github.com/Vyxal/Vyncode/blob/main/README.md), 20.875 bytes
```
…Ω\-‚Ç¨:@¬ªS‚Çå¬ªf4*‚Åº√ük6vF¬§J‚âà
```
[Try it Online!](https://vyxal.pythonanywhere.com/?v=2&c=1#WyJ+PSIsIiIsIsm9XFwt4oKsOkDCu1PigozCu2Y0KuKBvMOfazZ2RsKkSuKJiCIsIiIsIjBGQ0U5OEFDLTEzMjYtNEM3OS04RUJDLTk0OTA4REE4QjAzND0+IDFcbjAwMDAwMDAwLTAwMDAtMDAwMC0wMDAwLTAwMDAwMDAwMDAwMD0+IDFcbjBmY2U5OGFjLTEzMjYtNGM3OS04ZWJjLTk0OTA4ZGE4YjAzND0+IDFcbjBGQ0U5OGFjLTEzMjYtNGM3OS04RUJDLTk0OTA4ZGE4QjAzND0+IDFcblxuezBGQ0U5OEFDLTEzMjYtNEM3OS04RUJDLTk0OTA4REE4QjAzNH09PiAwXG4wR0NFOThBQy0xMzI2LTRDNzktOEVCQy05NDkwOERBOEIwMzQ9PiAwXG4wRkNFOThBQyAxMzI2LTRDNzktOEVCQy05NDkwOERBOEIwMzQ9PiAwXG4wRkNFOThBQy0xMzI2NEM3OS04RUJDLTk0OTA4REE4QjAzND0+IDBcbjBGQ0U5OEFDLTEzMjY0LUM3OS04RUJDLTk0OTA4REE4QjAzND0+IDBcbjBGQ0U5OEFDRC0xMzI2LTRDNzktOEVCQy05NDkwOERBOEIwMzQ9PiAwXG4wRkNFOThBQy0xMzI2LTRDNzktOEVCQy05NDkwOERBOEIwMzQtPT4gMFxuMEZDRTk4QUMtMTMyNi00Qzc5LThFQkMtOTQ5MDhEQThCMDM0LTEyPT4gMFxuMEZDRTk4QUMxMzI2NEM3OThFQkM5NDkwOERBOEIwMzQ9PiAwIl0=)
Bitstring:
```
00100110000000110100100100111101001111011101001010000101101010001100111010011110101100110110111011000100010111110110101000111001111000100010111010111000111011100101010
```
```
…Ω\-‚Ç¨:@¬ªS‚Çå¬ªf4*‚Åº√ük6vF¬§J‚âà¬≠‚Å°‚Äã‚Äé‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å°‚Å™‚Äè‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å¢‚Å™‚Äè‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å£‚Å™‚Äè‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å§‚Å™‚Äè‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å¢‚Å°‚Å™‚Äè‚Äè‚Äã‚Å°‚Å†‚Å°‚Äå‚Å¢‚Äã‚Äé‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å¢‚Å¢‚Å™‚Äè‚Å†‚Å™‚Å™‚Å†‚Å™‚Å™‚Å†‚Å™‚Å™‚Å†‚Å™‚Å™‚Å†‚Å™‚Å™‚Å†‚Å™‚Å™‚Å†‚Å™‚Å™‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å§‚Å¢‚Å™‚Äè‚Äè‚Äã‚Å°‚Å†‚Å°‚Äå‚Å£‚Äã‚Äé‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å¢‚Å£‚Å™‚Äè‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å¢‚Å§‚Å™‚Äè‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å£‚Å°‚Å™‚Äè‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å£‚Å¢‚Å™‚Äè‚Å†‚Å™‚Å™‚Å†‚Å™‚Å™‚Å†‚Å™‚Å™‚Äè‚Äã‚Å°‚Å†‚Å°‚Äå‚Å§‚Äã‚Äé‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å£‚Å£‚Å™‚Äè‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å£‚Å§‚Å™‚Äè‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å§‚Å°‚Å™‚Äè‚Äè‚Äã‚Å°‚Å†‚Å°‚Äå‚Å¢‚Å°‚Äã‚Äé‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å§‚Å£‚Å™‚Äè‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å§‚Å§‚Å™‚Äè‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å¢‚Å°‚Å°‚Å™‚Äè‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å¢‚Å°‚Å¢‚Å™‚Äè‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å¢‚Å°‚Å£‚Å™‚Äè‚Å†‚Å™‚Å™‚Äè‚Äã‚Å°‚Å†‚Å°‚Äå‚Å¢‚Å¢‚Äã‚Äé‚Äè‚Äã‚Å¢‚Å†‚Å°‚Äå‚Å¢‚Å£‚Äã‚Äé‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å¢‚Å°‚Å§‚Å™‚Äè‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å¢‚Å¢‚Å°‚Å™‚Äè‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å¢‚Å¢‚Å¢‚Å™‚Äè‚Äè‚Äã‚Å°‚Å†‚Å°‚Äå¬≠
…Ω\-‚Ç¨:                   # ‚Äé‚Å°to lowercase, split on "-" and push two copies to the stack
     @       ‚Åº          # ‚Äé‚Å¢does the vectorized length equal
      ¬ªS‚Çå¬ª              # ‚Äé‚Å£the compressed number 21113
          f4*           # ‚Äé‚Å§as a list of digits each multiplied by 4
              √ük6vF     # ‚Äé‚Å¢‚Å°if so, remove all of the characters that are in the string "0123456789abcdef"
# ‚Äé‚Å¢‚Å¢This is NOT regex, vyxal has regex elements
                   ¬§J‚âà  # ‚Äé‚Å¢‚Å£append an empty string and check if all elements are equal
üíé
```
Created with the help of [Luminespire](https://vyxal.github.io/Luminespire).
[Answer]
## Java, ~~172 bytes~~ 168 bytes (Thanks Wheat Wizard)
Kinda cheaty since I used java.util.UUID, but here goes:
```
import java.util.UUID;class ValidUUID{public static void main(String[] a){try{UUID.fromString(a[0]);System.out.println(1);}catch(Exception e){System.out.println(0);}}}
```
Ungolfed version:
```
import java.util.UUID;
class ValidUUID {
    public static void main(String[] a) {
        try {
            UUID.fromString(a[0]);
            System.out.println(1);
        } catch(Exception e) {System.out.println(0);}
    }
}
```
]