RegEx help?

I need to figure a fast way to find the enclosing /* and */ given a position in a string of text.

Finding the first

  1. locate the previous postion of a unclosed /* … there could be nested /* */
  2. if #1 succeeds (there may not BE a leading /*)
  3. find the closing */
/* start A
.... situation #1 would return A
/* start b
... situation #2 would return B
end b */
... situation #3 would return A. as well
end a */

this seems to work
this is one pattern split up across multiple lines with comments

(?x)                # free space mode
\/\*                # opening brackets
(?:                 # non-capturing group
[^\/\*]+            # not another opening or closing bracket
(?:\/\*[^\/]+\*\/)?  # optional substring within brackets
)*                  # end the non-capturing group and repeat it 0 or more times
[^/]*               # not the closing bracket
\*\/                # closing brackets

but doesn’t that start searching at the beginning of the string… ?
I need to search both directions from a specific position in the string
Ie. from any of the “situation” indicators above… Not search from “A” to find the end of “A”

I could be 10000 characters into the file, but only need to know if the current postion is inside an active “block” comment, this looks like it would find the “next” block comment

not without an anchor for start of line and end of line