Regex (ECMAScript), 61 bytes
^(?=(|x*)\1*(?=\1\b)(?!(((x+)x+)(?=\3+,)\3*\4)\2+,)(x*)).*,\5
Try it online!
Takes \$n\$ and \$B\$ from input in unary as strings of xs whose length represents the number, separated by a ,.
Uses my prime power regex, and the same expression for cycling through divisors of N from largest to smallest as used in this problem.
# Take input as N in unary, followed by a comma, followed by B in unary ^ (?= (|x*)\1*(?=\1\b) # cycle tail through all of the divisors of N, including N, # from largest to smallest; # \1 = the divisor, or zero if the divisor is N itself # Assert tail is a prime power (?! # Assert that the following cannot match ( # Capture \2 to be the following: ((x+)x+) # Cycle through all values of \4 and \3 such that \3 > \4 > 1 (?=\3+,) # such that \3 is a proper divisor of N \3*\4 # Cycle through all values of \2 > \3 that aren't divisible # by \3, by letting \2 = \3 * A + \4 where A >= 0 ) \2+, # where \2 is a proper divisor of N ) (x*) # \5 = the largest prime power factor of N ) .*, # tail = B \5 # Assert that \5 <= B
Regex (ECMAScript), 61 59 bytes
Adapting Neil's idea of taking the arguments in \$(B,n)\$ order saves 2 bytes:
^(x*),(?!(x*)\2*(?=\2\b)(?!(((x+)x+)(?=\4+$)\4*\5)\3+$)x\1)
Try it online!
(For convenience, this test harness takes the arguments in \$(n,B)\$ order and passes them to the regex in reverse order.)
# Take input as B in unary, followed by a comma, followed by N in unary ^ (x*), # \1 = B; tail = N (?! # Assert that the following cannot match (x*)\2*(?=\2\b) # cycle tail through all of the divisors of N, including N; # \2 = the divisor, or zero if the divisor is N itself # Assert tail is a prime power (?! # Assert that the following cannot match ( # Capture \3 to be the following: ((x+)x+) # Cycle through all values of \5 and \4 such that \4 > \5 > 1 (?=\4+$) # such that \4 is a proper divisor of N \4*\5 # Cycle through all values of \3 > \4 that aren't divisible # by \4, by letting \3 = \4 * A + \5 where A >= 0 ) \3+$ # where \3 is a proper divisor of N ) x\1 # Assert tail > B )
Regex (ECMAScript 2018 / .NET), 54 52 bytes
-2 bytes by using Neil's idea but with the arguments in \$(n,B)\$ order
$(?<!^\4*(?!(((x+)x+)(?=\2+,)\2*\3)\1+,)(x+\5),(x+))
Try it online! - ECMAScript 2018
Try it online! - .NET
This works by first capturing \$B\$, then asserting that there does not exist any \$a>B\$ for which \$a\$ is a prime power that divides \$N\$.
# Take input as N in unary, followed by a comma, followed by B in unary $ # head = B (?<! # Negative lookbehind; assert that it's not possible to find a # match for the following. Evaluated from right-to-left, so read # the inside of this from bottom to top (but go back to top-down # order for reading inside the negative lookbehind) ^\4* # Assert that \4 divides N # Assert tail is a prime power (?! # Negative lookahead; assert that the following cannot match ( # Capture \1 to be the following: ((x+)x+) # Cycle through all values of \3 and \2 such that \2 > \3 > 1 (?=\2+,) # such that \2 is a proper divisor of N \2*\3 # Cycle through all values of \1 > \2 that aren't divisible # by \2, by letting \1 = \2 * A + \3 where A >= 0 ) \1+, # where \2 is a proper divisor of N ) (x+\5) # \4 = tail = any divisor of N greater than B; the "^\5*" above # asserts it to be a divisor of N. Note that in most regex # engines, putting the "^\5*" later than the negative # assertion, as is the case here, results in a slowdown, as # non-divisors of N will be tested for being prime powers. ,(x+) # \5 = head = B )