Android Bluetooth ScanFilter Partial String Matching

后端 未结 1 1957
小蘑菇
小蘑菇 2021-01-19 15:23

I\'m looking to use a ScanFilter to search for a set of bluetooth devices. I know the address of all these devices starts with 00:A0:50, and then the last 6 digits vary, so

1条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-19 16:21

    Yes you can use regex & Pattern class

    use following regex to match string address

    00:A0:50:([A-Fa-f0-9]{2}:){2}[A-Fa-f0-9]
    

    see demo DEMO

    I'm surprised it doesn't take an array as input, I would think that would be a more common use case than a single MAC address.

    For now you can use loop(i.e for , while.. etc) and match the address

    0 讨论(0)
提交回复
热议问题