• As I said earlier, before executing the query

    replace all [ with [[]

    Do not replace ] with []]. Keep them as it is.

    For your example

    "a[k']p" becomes "a[[]k']p"

    So searching in database for "a[[]k']p"

    retrieves the records with "a[k']p"