3

It seems that underscore (_) is a wildcard character in Data Explorer. How do I escape it to search for an actual underscore?

Better - is there any indexing on words a la Lucene or RegEx support that I can access in the Data Explorer or do I have to do brute-force LIKE queries?

Even better - is there any way to do a search based on text, not markdown code?

For example, if I want to find all posts with the word "bat" in them (not the words "batch" or "rebate") but don't care if there's some formatting around "bat", do I have to write:

select [Post Link] from Posts 
where body like '% bat %'
or body like '% *bat* %'
or body like '% *bat* %' 
or body like '% bat* %' ... etc.
| |
  • If you could comment on my answer as to whether any of its suggestions worked, that could help future people with the same question. – msh210 May 20 '13 at 17:46
  • @msh210 I agree. I haven't gotten a chance to try anything. If your suggestion works, I will accept. Otherwise, I will let you know. – Charles Koppelman May 20 '13 at 17:59
2

I think the Data Explorer uses T-SQL. If that's right, then the following — based on https://stackoverflow.com/q/863534 and https://stackoverflow.com/q/194652 — should work:

It seems that underscore (_) is a wildcard character in Data Explorer. How do I escape it to search for an actual underscore?

Use [_].

Even better - is there any way to do a search based on text, not markdown code?

Not that I know of.

For example, if I want to find all posts with the word "bat" in them (not the words "batch" or "rebate") but don't care if there's some formatting around "bat", do I have to write:

select [Post Link] from Posts 
where body like '% bat %'
or body like '% *bat* %'
or body like '% *bat* %' 
or body like '% bat* %' ... etc.

This should work: body like '%[^a-z]bat[^a-z]%' (if search is case insensitive, anyway. I don't know whether it is). Or body like '%[ _*'"]bat[ _*.,;:!?'"]%', say.

| |

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .