Introduction
Lately I was learning regular, as you know, I have recorded the note about regular in last blog, I’m crazy about regular in some extends,for every function I met in the project,the first solution I come out is using regular, and the time is coming.
The exciting moment
Since we front end developers in my company is cooperating with the developer of Android and Ios, they provide us with the webview and we develop the pages of h5, which is so called hybrid. Ok, no more useless words,the function is we need to decrypt the data fetched from backend interface,some fields in the data is encrypted for the security’s sake. Having known this, I suddenly think of regular, it can perfectly solve this problem, considering it for a moment, I consult with the backend developer, letting them create the fields expression special, so I can easily use regular.
Show the code
1 | export const decrypt = { |
Thanks
At first, it is running smoothly in my local environment, but put it into the webview, a lot of problems come out, the tough one is, it is asynchronous to get the decrypted data from ios, I know it should be using Promise, but I don’t know where to put it in, it’s really sucks,furtunately, another colleague is good at it,helping me solved it.Here give my thanks to scopeWu and I really need to put some strength to understand promise deeply.
In the end
Without complex loop and check, the regular makes it more convenient to achieve the goal.A little happy successfuly to made it. And there is a long way to go to be good at regular.