Assuming you're talking about HTML, no. Regex simply matches string patterns, and nothing more. It can't prevent someone from editing an input field. It's not the right tool for the job.
You're likely looking for the
readonly attribute for an HTML input. https://www.w3schools.com/tags/att_input_readonly.asp