If you have a regular polygon with $N$ sides centered at $(x_0, y_0)$ with circumradius $r$, the vertices are $(x_i, y_i)$,
$$\left\lbrace \begin{aligned}
x_i &= x_0 + r \cos\left(\frac{2 \pi i}{N}+ \theta\right) \\
y_i &= y_0 + r \sin\left(\frac{2 \pi i}{N}+ \theta\right) \\
\end{aligned} \right . , \quad i = 1, 2, \dots, N$$
where $\theta$ represents the rotation of the polygon, and is usually either $0$ (first vertex is right from center) or $\pi/2$ (first vertex is above the center). If you have a left-handed coordinate system, where $y$ coordinate increases down, use $y_i = y_0 - r \sin \dots$ instead.
The edges of the regular polygon are line segments between $(x_i, y_i)$ and $(x_{i+1}, y_{i+1})$ for $i = 1, \dots, N-1$, and between $(x_N, y_N)$ and $(x_1, y_1)$.
The problem thus simplifies to finding the intersection between a line and a line segment. You test each polygon edge line segment against your line to see if there is an intersection. You will often find two, because the line usually intersects the polygon twice; in such cases, you pick the closer intersection.
First, let's say your line (which extends to infinity) starts at $(x_s, y_s)$, and passes through point $(x_e, y_e)$. We'll parametrise it using $t$, such that if the intersection point is at the start $t = 0$, and if at $(x_e, y_e)$ $t = 1$. Or, more generally, the intersection point $t$ corresponds to
$$\left\lbrace \begin{aligned}
x &= (1 - t) x_s + t x_e = x_s + t (x_e - x_s) \\
y &= (1 - t) y_s + t y_e = y_s + t (y_e - y_s) \\
\end{aligned} \right.$$
The smaller the magnitude (absolute value) of $t$, $\lvert t \rvert$, the closer the point is to $(x_s, y_s)$. The exact distance $L = \lvert t \rvert \sqrt{(x_e - x_s)^2 + (y_e - y_s)^2}$ in your coordinate units.
For the line segment, let's use $(x_a, y_a)$, $(x_b, y_b)$, and $\tau$, in exactly the same manner. In this case, note that if $\tau \lt 0$ or $\tau \gt 1$, the intersection point is not in the line segment, but further away on the line extending from the line segment, and is thus not a real intersection.
This kind of problem is solved using a system of equations. In this case, we have
$$\left\lbrace \begin{aligned}
x_s + t (x_e - x_s) &= x_a + \tau (x_b - x_a) \\
y_s + t (y_e - y_s) &= y_a + \tau (y_b - y_a) \\
\end{aligned} \right .$$
and we find a simultaneous solution for $t$ and $\tau$. There are easy ways to do this by hand, but since you are a programmer, you could use something like Maxima (completely free; wxMaxima is the one with a nice user interface also):
solve([ x_s + t*(x_e - x_s) = x_a + tau*(x_b - x_a),
y_s + t*(y_e - y_s) = y_a + tau*(y_b - y_a) ], [ t, tau ]);
The solution is
$$\begin{aligned}
d &= (x_b - x_a) (y_e - y_s) - (y_b - y_a) (x_e - x_s) \\
t &= \frac{(x_a - x_b) y_s + (x_b - x_s) y_a + (x_s - x_a) y_b}{d} \\
\tau &= \frac{(x_a - x_e) y_s + (x_e - x_s) y_a + (x_s - x_a) y_e}{d} \\
\end{aligned}$$
but note that if the lines are parallel (and thus either do not intersect at all, or intersect at the entire line segment), then $d = 0$.
Because your polygons are closed, you can ignore that case, because the preceding and following edges will intersect with the line if the line extends the line segment.
Do remember that you might find two different $t$ in a polygon, so you cannot just exit the check early, as the smaller $t$ in magnitude (absolute value) is the correct first intersection.
If you did want to find out if your line intersects point $(x_c, y_c)$:
If $x_s = x_e$, your line is vertical.
If $x_c = x_e$, the line intersects the point at $t = \frac{y_c - y_s}{y_e - y_s}$.
If $y_s = y_e$, your line is horizontal.
If $y_c = y_e$, the line intersects the point at $t = \frac{x_c - x_s}{x_e - x_s}$.
Otherwise, calculate $$\begin{aligned}
t_x &= \frac{x_c - x_s}{x_e - x_s} \\
t_y &= \frac{y_c - y_s}{y_e - y_s} \\
\end{aligned}$$
If $t_x = t_y$, the line intersects the point at $t = t_x = t_y$.
Note that since you will be floating-point numbers that will usually have a bit of rounding error (since they cannot represent most numbers exactly), you'll want to use check abs(t_x - t_y) <= epsilon, where epsilon is the largest value you consider small enough to be zero. Here, it depends on the distance between $(x_s, y_s)$ and $(x_e, y_e)$, and I'd suggest using
$$\epsilon = \frac{0.5 L}{\sqrt{(x_e - x_s)^2 + (y_e - y_s)^2}}$$
where $L$ is approximately the per-coordinate error you accept. If your coordinates are integers, then $L = 1$; if your coordinates have three decimal digits, then $L = 0.001$, and so on.
Similarly, instead of 0 \le \tau \le 1, you might wish to check for $-\epsilon \le \tau \le 1 + \epsilon$ instead (with $\epsilon = \frac{0.5 L}{\sqrt{(x_b - x_a)^2 + (y_b - y_a)^2}}$ now), i.e. "extending" the line segment by rounding error at both ends.
If you use single-precision floating-point (float), and your coordinates are roughly integers, you can just stick with $\epsilon = 0.001$; and if double precision (double), with $\epsilon = 0.000001$, since these should be greater than the rounding errors, although the "allowed error" will vary a bit depending on the distance between the points and the length of the line segment.